What are java enums? How do they work? Where could I used them and how?
Can I do without using enums in an app or are they so powerful that Its better to use them than i
Think of Enum as follows
public class MyEnum {
// Object instantiated at declaration
public static final MyEnum ONE = new MyEnum();
public static final MyEnum TWO = new MyEnum();
public static final MyEnum THREE = new MyEnum();
// Notice a private constructor
// There is no way outside MyEnum class call it
private MyEnum() { ... }
}
So a MyEnum as a enum would be
public enum MyEnum {
ONE,
TWO,
THREE;
}
Both are similar
regards,