Sync Factory Method, Abstract Factory, Builder, Prototype to Java 25; fix post/code mismatches
This commit is contained in:
19
01-creational/singleton/AppConfig.java
Normal file
19
01-creational/singleton/AppConfig.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package singleton;
|
||||
public class AppConfig {
|
||||
|
||||
private AppConfig() {
|
||||
System.out.println("Reading configuration from file...");
|
||||
}
|
||||
|
||||
private static class Holder {
|
||||
static final AppConfig INSTANCE = new AppConfig();
|
||||
}
|
||||
|
||||
public static AppConfig getInstance() {
|
||||
return Holder.INSTANCE;
|
||||
}
|
||||
|
||||
public String getProperty(String key) {
|
||||
return System.getProperty(key, "(not set)");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user