Possible Duplicate:
How To Print String representation of Color in Java
I have a method called getColor() that returns a color (like Color.BLACK). Is there a way to convert getColor() into a string of its name?
String test = getColor().toString();
If getColor() returns Color.BLACK, then
String test = Color.BLACK.toString();
System.out.println(test);
OUTPUT
java.awt.Color[r=0,g=0,b=0]
toString()can never reproduce the original name of the variable that was used to store that instance (because there can be more than one containing that instance).One way would be to manually compare the
Colorinstance: