Building on what has been written in SO question Best Singleton Implementation In Java - namely about using an enum to create a singleton - what are the differences/pros/cons between (constructor omitted)
public enum Elvis {
INSTANCE;
private int age;
public int getAge() {
return age;
}
}
and then calling Elvis.INSTANCE.getAge()
and
public enum Elvis {
INSTANCE;
private int age;
public static int getAge() {
return INSTANCE.age;
}
}
and then calling Elvis.getAge()