Pass floats as string literals to a methodTag(s): String/Number

Color c = new Color(0.1,0.2,0.4);
returns "Incompatible type for constructor. Explicit cast needed to convert double to int." even if the constructor Color (float r, float g, float b) is valid. That's because the compiler interprets numbers like 0.1 as double not float. You must use the suffixe "f" to indicate that the number is a float.
Color c = new Color(0.1f,0.2f,0.4f);

blog comments powered by Disqus