public class SingletonExample {
	
	// This is a reference either to null or to the one
	// instance that is allowed
	private static SingletonExample single_instance = null;
	
	// Usually protected to allow a generic class
	// to represent the idea of a singleton and use
	// derived classes to add singleton behaviour to
	// something
	protected SingletonExample() {
	}
	
	// This is a static method so it can only access
	// static fields and doesn't need an instance to
	// be called on
	public static SingletonExample getInstance() {
		// Create the instance if it's the first time
		if (single_instance==null) single_instance = new SingletonExample();
		
		// Either way, return a reference to the instance
		return single_instance;
	}

}
