Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java singleton

public class SingletonOnDemand {
	
	private SingletonOnDemand () {}
	private static class Singleton {
		private static final SingletonOnDemand instance = new SingletonOnDemand();
	}
	
	public static SingletonOnDemand getInstance () {
		System.out.println("create instance");
		return Singleton.instance;
	}
}
Source by dzone.com #
 
PREVIOUS NEXT
Tagged: #java #singleton
ADD COMMENT
Topic
Name
6+3 =