P
puzzlecracker
Guys, I saw the following code that, allegedly, implements
Singleton's pattern via the enum... I don't fully understand it since
I've just got introduced to java's enums (pardon me, I am a C++
veteran with old-fashion understanding of the term). Please elaborate
what it means.
public enum SingletonUsingEnum
{
INSTANCE;
public void leaveTheBuilding()
{
System.out.println("A single instance");
}
}
thanks,
Puzzlecracker
Singleton's pattern via the enum... I don't fully understand it since
I've just got introduced to java's enums (pardon me, I am a C++
veteran with old-fashion understanding of the term). Please elaborate
what it means.
public enum SingletonUsingEnum
{
INSTANCE;
public void leaveTheBuilding()
{
System.out.println("A single instance");
}
}
thanks,
Puzzlecracker