Why do we need to make instance variable as static?
Why do we need to make instance variable as private?
Why do we need to mark constructor with private?
Why do we need to make instance variable as private?
Why do we need to mark method with static, synchronized?
Please brief me with when to use and where to use with 3 or 4 examples?
If somebody has already used this concept, please put some insight into it.
public class SingleTon
{
private static SingleTon instance;
private SingleTon()
{
}
public static synchronized SingleTon getSingleTonInstance()
{
if(instance ==null)
{
instance = new SingleTon();
}
return instance;
}
}