OnJava8-Examples/enumerated/OverrideConstantSpecific.java

23 lines
534 B
Java
Raw Normal View History

2015-04-20 15:36:01 -07:00
//: enumerated/OverrideConstantSpecific.java
2015-05-29 14:18:51 -07:00
// <20>2015 MindView LLC: see Copyright.txt
2015-04-20 15:36:01 -07:00
import static net.mindview.util.Print.*;
public enum OverrideConstantSpecific {
NUT, BOLT,
WASHER {
2015-05-05 11:20:13 -07:00
@Override
2015-04-20 15:36:01 -07:00
void f() { print("Overridden method"); }
};
void f() { print("default behavior"); }
public static void main(String[] args) {
for(OverrideConstantSpecific ocs : values()) {
printnb(ocs + ": ");
ocs.f();
}
}
} /* Output:
NUT: default behavior
BOLT: default behavior
WASHER: Overridden method
*///:~