Hey guys,
I'm curious, why does the Color class have two variable for each color. For example, for color white, WHITE and white. Why does it have both if the do they same job?
-Mel
Printable View
Hey guys,
I'm curious, why does the Color class have two variable for each color. For example, for color white, WHITE and white. Why does it have both if the do they same job?
-Mel
I suspect it has something to do with the Java naming conventions. Prior to Java 1.4, the there were only camel case static color fields (white, black, etc.). However, beginning in 1.4 they added the all-caps versions, probably to indicate that these are to be treated as constants.
This is just speculation, though. I didn't find any hard evidence why the upper case versions were added.
I see. Sounds like it very well is the reason. Though if it is, why do the lower case variables still exist?
My guess would be that Sun/Oracle would be rather careful before breaking existing code that uses the lowercase variables.Quote:
why do the lower case variables still exist?
I'd agree with helloworld's hypothesis. And if this is the case they probably still exist for backwards compatibility - all legacy code that relies on the lower case would break if they were removed, and in many cases updating legacy code is a nightmare and not worth the effort.