Singleton can be broken by usingĀ Reflection and the below code demonstrates the same.
Singleton Class
package com.test.singleton;
public class Singleton {
private static Singleton singleton = null;
private Singleton() {
System.out.println("Running Constructor......");
}
public static Singleton getInstance(){
if(singleton==null)
singleton = new Singleton();
return singleton;
}
}
