I'm not sure I understand what you mean in your question, so I will answer what I think you are asking.
Enum can be a native file in Java. For example, you might have a TrafficLight file that is inside:
public enum TrafficLight {
RED(1),
GREEN(2),
YELLOW(3);
private final int duration;
TrafficLight(int duration) {
this.duration = duration;
}
public int getDuration() {
return this.duration;
}
}
Then you can use this enumeration from your test project (TrafficLightPrj.java). For instance:
public class TrafficLightprj {
public static void main(String[] args) {
for(TrafficLight light: TrafficLight.values()) {
System.out.println("The traffic light value is: " +light);
System.out.println("The duration of that trafic light value is: " +light.getDuration());
}
}
}
source
share