A classic and fool-proof example of Singleton sample is as follows,
Considering that we need to create a singleton for an Employee object(some POJO, for easier understanding), a Singleton can be expressed as,
class SampleSingleton{
private static Employee empObject= new Employee();
public static Employee getEmployee(){
return empObject;
}
}
On start up, I create a singleton object and assign it to the empObject, and each time I only send that single object to the caller.
Considering that we need to create a singleton for an Employee object(some POJO, for easier understanding), a Singleton can be expressed as,
class SampleSingleton{
private static Employee empObject= new Employee();
public static Employee getEmployee(){
return empObject;
}
}
On start up, I create a singleton object and assign it to the empObject, and each time I only send that single object to the caller.








