Managing configurations in java (initial config / save/load config)

后端 未结 3 2008
自闭症患者
自闭症患者 2021-01-23 11:41

I got a class Config wich looks like that:

public Class Config {

    public static int someIntValue = 0;
    public static String someText = \"some text\";

}
         


        
3条回答
  •  情书的邮戳
    2021-01-23 12:09

    Usually in Java for configuration use properties files. And then use ResuorseBundle for reading properties.

    Your "singleton" is not a Singleton in the conventional sense. 1) Field instance must be private 2) Remove SetInstance method 3) And you should make your singleton thread safe.

提交回复
热议问题