Pin It

How to implement Singleton Design Pattern in java with a simple program ?

Program to implement Singleton Design Pattern in java with a simple program

package com.hubberspot.singleton;

public class Singleton {

   private static Singleton singleInstance;
  
   private Singleton() {}
 
   public static synchronized Singleton getInstance() {
      if (singleInstance == null) {
   singleInstance = new Singleton();
      }
      return singleInstance;
   }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        throw new CloneNotSupportedException();
    }
  
}





Please Give Us Your 1 Minute In Sharing This Post!
SOCIALIZE IT →
FOLLOW US →
SHARE IT →
Related Posts Plugin for WordPress, Blogger...

Post your related queries below ...

comments powered by Disqus
Powered by Blogger.
 
© 2012 Learn Java by Examples Template by Hubber Spot