package com.pastebin.maroph; /** * Java Singleton sample. *
* This code is based on the following article: *
* Title : Effective Ways to Implement and Use the Singleton Design Pattern * Sample : Class Holder Singleton * URL : https://community.oracle.com/docs/DOC-918906 **
*/ public class JavaSingleton { /** Private constructor */ private JavaSingleton() { /* the body of the constructor here */ } /** * Access point to the unique instance of the singleton. * @return return the singleton */ public static JavaSingleton getInstance() { return JavaSingletonHolder.INSTANCE; } /** * Private singleton holder class. */ private static class JavaSingletonHolder{ /** create the singleton instance */ private static final JavaSingleton INSTANCE = new JavaSingleton(); } }