This is a singleton class.
I wanted to know the ways to we break the singleton logic in this code
class Employee{ // class starts
private Employee(){} // private constructor
private static Employee emp;
/*static block*/
static {
if (emp==null)
{
emp=new Employee();
}
}
/* static method*/
public static Employee getEmployee()
{
return emp;
}
}
You should also do below in constructor to avoid object creation by reflection
}