Skip to content

Instantly share code, notes, and snippets.

@gotoark
Last active September 4, 2018 02:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gotoark/7e431ab7743e82c94fb58405dea3bfdf to your computer and use it in GitHub Desktop.
Save gotoark/7e431ab7743e82c94fb58405dea3bfdf to your computer and use it in GitHub Desktop.
Singleton Example
package singleton;
public class EagerInitialization {
//1.private Constructor
private EagerInitialization() {
}
//2.Only Instance of the Class
private static final EagerInitialization instance = new EagerInitialization();
//3.Public method to enable global access
public static EagerInitialization getClassInstance() {
return instance;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment