[Solved] Java static instance


This code reminds me of Singleton Class in java.

public class Runa {

   private static Runa singleton = new Runa( );

   /* A private Constructor prevents any other
    * class from instantiating.
    */
   private Runa() { }

   /* Static 'instance' method */
   public static Runa getInstance( ) {
      return singleton;
   }

   /* Other methods protected by singleton-ness */
   protected static void demoMethod( ) {
      System.out.println("demoMethod for singleton");
   }
}

FYI, Singleton ensures that only one object of created for class Runa inside the application. Try to google a bit for more understanding of Singleton usage in java

Links:
https://www.tutorialspoint.com/java/java_using_singleton.htm

Best of Luck

1

solved Java static instance