Possible Duplicate:
Difference between Color.red and Color.RED
I have seen that the Java class java.awt.Color
contains couples of fields with the same name, once in capital letters and once not. For example: Color.black
and Color.BLACK
. Is there a difference?
edit:
… and if not, why are there two of them?
Just take a look at documentation:
public static final Color black
The color black. In the default sRGB space.
public static final Color BLACK
The color black. In the default sRGB space. Since: 1.4
No, there is no difference.
Both of them exist because black
has been introduced with the Color
class, then they realized that it wasn't following naming convention so they added the capitalized version (you can see since 1.4 written). They didn't remove the old ones to not break any < 1.4 code.
There is no difference excpet that Color.BLACK
follows the naming conventions for static final fields.
From what I see in source there is no difference
public final static Color black = new Color(0, 0, 0);
public final static Color BLACK = black;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With