I have a situation where I need the Checker enumeration below, used in several classes:
package Sartre.Connect4; public enum Checker { EMPTY, RED, YELLOW }
so I put Checker in the Checker.java file, and then from the classes that need it, I just do the following:
Example:
public Cell(){ currentCell = Checker.EMPTY; }
Example:
public Cell(Checker checker){ currentCell = checker; }
and the code compiles fine and works great.
So what is my question? good to be new to Java I just wonder if the way I use Checker without encapsulating it in a class is a reliable implementation?
this may be because an enum declaration defines a class (called an enum type) , as described in the article on renaming Java documents.
iTEgg source share