upper and lower case static color names in Color

C

ChrisC

Just out of curiosity, why are there duplicate colors, such as
Color.red and Color.RED in the java Color class? Color.RED would be
the standard notation for a static final...

Chris
 
K

Knute Johnson

ChrisC said:
Just out of curiosity, why are there duplicate colors, such as
Color.red and Color.RED in the java Color class? Color.RED would be
the standard notation for a static final...

Chris

The lower case names were in the original version of Java before they
standardized on upper case names for the static finals. The upper case
names were added in version 1.4. Use the upper case names for any new code.
 
R

Roedy Green

Just out of curiosity, why are there duplicate colors, such as
Color.red and Color.RED in the java Color class? Color.RED would be
the standard notation for a static final...

It is historical. Originally they were all lower case. Then someone
pointed out this violated the static final all upper case naming
convention, and Sun fixed it. They had to leave the lower case names
to avoid breaking existing code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top