<<< Enumeration methods | Index | toString( ) example, cont. >>> |
An enumeration that overrides the toString() method:
public enum ShippingType { UPS_NEXT_DAY, UPS_SECOND_DAY, UPS_GROUND; @Override public String toString() { String str = "UNKNOWN"; if ( this.ordinal() == 0 ) { str = "UPS Next Day (1 business day)"; } else if ( this.ordinal() == 1 ) { str = "UPS Second Day (2 business days)"; } else if ( this.ordinal() == 2 ) { str = "UPS Ground (5 to 7 business days)"; } return str; } }
<<< Enumeration methods | Index | toString( ) example, cont. >>> |