Simple Java singleton example

// May 26th, 2009 // 2 Comments // Programming

public class SimpleSingleton {
  private static SimpleSingleton singleInstance =  new SimpleSingleton();

  //Marking default constructor private
  //to avoid direct instantiation.
  private SimpleSingleton() {}

  //Get instance for class SimpleSingleton
  public static SimpleSingleton getInstance() {

  return singleInstance;
  }
}

Contact me to advertise here

2 Responses to “Simple Java singleton example”

  1. Thirty Days says:

    Nice Post, Thanks.

Leave a Reply