This design pattern commonly used for java.default constructor is avoid multiple object creation.
A static modifier is applied to the instance method that returns the object as it then makes this method a class level method that can be accessed without creating an object.
Default Constructor
private static SingletonClass ourInstance = new SingletonClass(); public static SingletonClass getInstance()
{
return singletonObj;
}
private SingletonClass() {
}
No comments:
Post a Comment