18 lines
357 B
Java
18 lines
357 B
Java
package javadevjournal.design.creational.singleton;
|
|
|
|
/**
|
|
* @author Kunwar
|
|
*/
|
|
public class Singleton {
|
|
|
|
/* private instance variable */
|
|
private static Singleton instance = new Singleton();
|
|
|
|
/* private constructor */
|
|
private Singleton(){}
|
|
|
|
/* returns the same object */
|
|
public static Singleton getInstance(){
|
|
return instance;
|
|
}
|
|
} |