Are you new? Read the FAQ and catch up on!
655 views

Singleton pattern in Java

Basic implementation of the singleton pattern in Java:

Java
  1. public class Singleton {  
  2.  
  3.   static class SingletonHolder {  
  4.     static Singleton instance = new Singleton();  
  5.   }  
  6.  
  7.   public static Singleton getInstance() {  
  8.     return SingletonHolder.instance;  
  9.   }  
  10.  
  11. }
  12.  

­

Tags: Java singleton pattern

Embed: