Created
April 15, 2024 15:58
-
-
Save lol97/af05365121f30cef020b07830b287a35 to your computer and use it in GitHub Desktop.
example early instantiation singleton in java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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