<<< Enumeration syntax | Index | Enumeration methods >>> |
A method that uses the enumeration as a parameter type:
public static double getShippingAmount( ShippingType st ) { double shippingAmount = 2.99; if ( st == ShippingType.UPS_NEXT_DAY ) { shippingAmount = 10.99; } else if ( st == ShippingType.UPS_SECOND_DAY ) { shippingAmount = 5.99; } return shippingAmount; }
A statement that calls the method
double shippingAmount = getShippingAmount( ShippingType.UPS_SECOND_DAY ); // Wrong type, not allowed --- will not compile: double shippingAmount2 = getShippingAmount(1);
<<< Enumeration syntax | Index | Enumeration methods >>> |