Slide 14
Slide 14 text
&MWJT-JWFT
public class Elvis {
public static final Elvis INSTANCE = new Elvis();
private final int beltSize;
private static final int CURRENT_YEAR = Year.now().getValue();
private Elvis () { beltSize = CURRENT_YEAR - 1930; }
public int beltSize() { return beltSize; }
public static void main(String... args) {
System.out.println("Elvis wears size "
+ INSTANCE.beltSize() + " belt.");
}
}
1) Elvis wears size 0 belt.
2) Elvis wears size -1930 belt.
3) Elvis wears size 93 belt.
4) Null Pointer Exception