Enums with Behavior

You can define abstract methods in Enum, since you cannot instantiate instances of Enum type. The implementation of those abstract methods are in the predefined constants. The constants may be called upon to carry out a certain type of behavior.

These are three Enum constants:

public enum ShuttleType {

    COLUMBIA {
        public Shuttle getShuttle() {
            return new Columbia();				
        }
    },		
	
    DISCOVERY {	
        public Shuttle getShuttle() {
            return new Discovery();			
        }
    };
	
    abstract Shuttle getShuttle();
}

They can be called upon like this:

public static void main(String[] args) {
    Shuttle s = ShuttleType.COLUMBIA.getShuttle();
}