KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > testlib > modifiers > EffectivelyFinal


1 package testlib.modifiers;
2
3 /**
4  * Because this class has a package-scope constructor, no subclass of this
5  * class can ever be created. And because of that, it is not a problem if
6  * this class is declared "final" in a later version.
7  * <p>
8  * Classes with only private constructors are commonly used to implement
9  * an "enumerated type" in java, as is done here.
10  */

11
12 public final class EffectivelyFinal
13 {
14     int val;
15     
16     public static final EffectivelyFinal ZERO = new EffectivelyFinal(0);
17     public static final EffectivelyFinal ONE = new EffectivelyFinal(1);
18     
19     private EffectivelyFinal(int i)
20     {
21         val = i;
22     }
23     
24     public int getValue()
25     {
26         return val;
27     }
28 }
29
Popular Tags