Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Java Singleton Class Syntax

class SingletonExample {

   // private field that refers to the object
   private static SingletonExample singleObject;
                                              
   private SingletonExample() {
      // constructor of the SingletonExample class
   }

   public static SingletonExample getInstance() {
      // write code that allows us to create only one object
      // access the object as per our need
   }
}
Source by dzone.com #
 
PREVIOUS NEXT
Tagged: #Java #Singleton #Class #Syntax
ADD COMMENT
Topic
Name
4+3 =