Pass floats as string literals to a methodTag(s): String/Number
About cookies on this site
Cookies are used to collect and analyze information on site performance and usage.
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);
mail_outline
Send comment, question or suggestion to howto@rgagnon.com