How to add new System Properties in java

后端 未结 3 417
不知归路
不知归路 2021-01-03 19:12

Is it possible to add new values to Java System Properties. If there is any how can introduce new keys with there corresponding values in Java System Properties.

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-03 20:09

    Yes:

    public static void main(String args[]) {
        String key = "a new property";
        System.setProperty(key, "a property with a value");
        System.out.println(System.getProperty(key));
    }
    

提交回复
热议问题