01: package testlib.modifiers;
02:
03: /**
04: * Because this class has a package-scope constructor, no subclass of this
05: * class can ever be created. And because of that, it is not a problem if
06: * this class is declared "final" in a later version.
07: * <p>
08: * Classes with only private constructors are commonly used to implement
09: * an "enumerated type" in java, as is done here.
10: */
11:
12: public final class EffectivelyFinal {
13: int val;
14:
15: public static final EffectivelyFinal ZERO = new EffectivelyFinal(0);
16: public static final EffectivelyFinal ONE = new EffectivelyFinal(1);
17:
18: private EffectivelyFinal(int i) {
19: val = i;
20: }
21:
22: public int getValue() {
23: return val;
24: }
25: }
|