OnJava8-Examples/enums/OverrideConstantSpecific.java

23 lines
532 B
Java
Raw Normal View History

2015-06-15 17:47:35 -07:00
//: enums/OverrideConstantSpecific.java
// <20>2015 MindView LLC: see Copyright.txt
import static com.mindviewinc.util.Print.*;
public enum OverrideConstantSpecific {
NUT, BOLT,
WASHER {
@Override
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
*///:~