Hi,
As we know that a constant specific class body will usually have a overriden method. For example in below code take from
SCJP book, getLidCode() method is overriden in LARGE and EXTRA_LARGE constants. Notice that EXTRA_LARGE constant has another method defined getSpecial(), Can anyone tell me how to invoke getSpecial()?
enum CoffeeSizesWithOverriden {
SMALL(1), BIG(3), LARGE(5){
public
String getLidCode() {
return "B";
}
}, EXTRA_LARGE(10){
public String getLidCode() {
return "C";
}
int special=10;
public int getSpecial() {
return special;
}
};
private int ounces;
CoffeeSizesWithOverriden(int ounces) {
this.ounces = ounces;
}
public int getOunces() {
return ounces;
}
public String getLidCode() {
return "A";
}
};
Thanks
Deepak