Used to ensure that a class only has one instance, and provide a global point of access to it. Often used when you only want one session. For:

  • Database communication

Implementation

// final class to prevent other classes from extending it
final class Manager {
	private static Manager manager;
	private Manager() {
	}
	public static Manager getInstnace(){
		if (manager == null){
			manager = new Manager();
		}
		return manager;
	}
}