Something like so would defy the purpose of the Singleton:
public class BadSingleton
{
private BadSingleton()
{
}
public BadSingleton getInstance()
{
return new BadSingleton();
}
}
The above will return a new instance of the BadSingleton
class everytime that the getInstance()
method is called. This will allow for various instances of the class which defies the purpose of the Singleton design pattern.
A similar scenario can also be achieved by using multiple class loaders (even if the Singleton is written correctly).