Skip to content

Instantly share code, notes, and snippets.

@bhawna94
Created June 15, 2020 06:23
Show Gist options
  • Save bhawna94/383999f5bcb23b431d5959d384ae6438 to your computer and use it in GitHub Desktop.
Save bhawna94/383999f5bcb23b431d5959d384ae6438 to your computer and use it in GitHub Desktop.
class Singleton {
//static field
private static Singleton object;
//private Construtor
private Singleton() {}
//static method
public static synchronized Singleton getInstance()
{
if (object == null)
object = new Singleton();
return object;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment