Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between Color.black and Color.BLACK? [duplicate]

Tags:

java

field

colors

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?

like image 778
SteeveDroz Avatar asked Jun 25 '12 11:06

SteeveDroz


3 Answers

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.

like image 63
Jack Avatar answered Nov 15 '22 03:11

Jack


There is no difference excpet that Color.BLACK follows the naming conventions for static final fields.

like image 29
tom Avatar answered Nov 15 '22 02:11

tom


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;
like image 44
Pshemo Avatar answered Nov 15 '22 03:11

Pshemo