Skip to content

Instantly share code, notes, and snippets.

@lol97
Created April 15, 2024 15:58
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 lol97/af05365121f30cef020b07830b287a35 to your computer and use it in GitHub Desktop.
Save lol97/af05365121f30cef020b07830b287a35 to your computer and use it in GitHub Desktop.
example early instantiation singleton in java
package sufyan97_blog.design_pattern;
class ConfigEarly {
private static ConfigEarly configEarly = new ConfigEarly(); //terbentuk ketika load time
private ConfigEarly() {
}
public static ConfigEarly getConfigEarly() {
return configEarly;
}
}
public class SingletonEarly {
public static void main(String[] args) {
System.out.println(ConfigEarly.getConfigEarly().hashCode());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment