sekkaro
sekkaro

Reputation: 13

Declaring the field of a class without prefixing it with the class

private static final Color DEFAULT_PEN_COLOR   = BLACK;

private static final Color DEFAULT_CLEAR_COLOR = WHITE;

This is a part of my code thats is having an error that says that the symbols BLACK and WHITE cannot be identified, even when I put import java.awt.Color. What do I need to do?

Upvotes: 1

Views: 57

Answers (1)

davidxxx
davidxxx

Reputation: 131526

You have to use static imports if you don't want to prefix the Color class :

import static java.awt.Color.*;

or else you have to prefix the fields with Color:

Color.BLACK 
Color.WHITE

Upvotes: 5

Related Questions