Reputation: 168
Color.GREEN
looks like an attribute and not an object if so then how can I assign class member(Color.GREEN
) to an object reference of type Color?
import java.awt.*;
public class StopLight {
public static final Color GREEN = Color.GREEN;
public static final Color YELLOW = Color.YELLOW;
public static final Color RED = Color.RED;
public StopLight() {
state = GREEN;
}
private Color state;
}
Upvotes: 0
Views: 483
Reputation: 14238
It is a public static object defined in java awt's Color
:
/**
* The color green. In the default sRGB space.
*/
public final static Color green = new Color(0, 255, 0);
/**
* The color green. In the default sRGB space.
* @since 1.4
*/
public final static Color GREEN = green;
So you can access it as Color.GREEN
.
Upvotes: 2