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