First page Back Continue Last page Overview Graphics
Enums – what about int value
In old way (in java 1.4) any constant has an int value which can be used outside of Java
public static final int STATUS_INUSE = 3;
public enum Planet {
MERCURY (3.303e+23),
VENUS (4.869e+24),
EARTH (5.976e+24);
private final double mass; // in kilograms
Planet(double mass) {
this.mass = mass;
}
private double mass() { return mass; }
}
Planet.EARTH.mass();