String s1 = "myName";
System.setProperty(s1, "false");
System.setProperty("yourName", "true");
System.out.println(Boolean.getBoolean("myName"));
System.out.println(Boolean.getBoolean("yourName"));
请教一下为什么输出:
false
true
这种问题,自己翻一下源码看一下,立马就能理解
public static boolean getBoolean(String name)当且仅当以参数命名的系统属性存在,且等于 “true” 字符串时,才返回 true。