Eager initialised Singleton Pattern.








This  example   of      Eager   initialised   Singleton Pattern.



/**

*   Eager   initialized   Singleton Pattern.
 *
 *  @auther  Mukesh Jha
*/


class  SingleInstance{
   
      private  final static  SingleInstance  singleInstance=new SingleInstance();
    
   
    
     private SingleInstance(){}
    
      public static  SingleInstance  getInstance(){
    
        return  singleInstance ; 
     }  
    
     public void  printHere(){
      
      System.out.println("Singleton Design Pattern");
     }
   
   }



  public class Singledesignpattern {

  public static void main(String args[]){
  
SingleInstance.getInstance().printHere();
 
     
     }


 }
 Program  Output :

 Singleton Design Pattern

Eager initialised Singleton Pattern. Eager   initialised   Singleton Pattern. Reviewed by Mukesh Jha on 7:02 AM Rating: 5

No comments:

Add your comment

All Right Reserved To Mukesh Jha.. Theme images by Jason Morrow. Powered by Blogger.