在Boolean类里的getBoolean(String name)方法。我输入了“TEMP”和“classpath”等一些系统环境变量,但是放回值不是true.而是false. 输入什么,放回值可以使true.

解决方案 »

  1.   

    Properties p = System.getProperties();
    p.setProperty("test", "true");
    System.out.println("Boolean.getBoolean():" + Boolean.getBoolean("test"));
      

  2.   


    static boolean getBoolean(String name) 
              Returns true if and only if the system property named by the argument exists and is equal to the string "true".
      

  3.   

    If there is no property with the specified name, or if the specified name is empty or null, then false is returned.
      

  4.   

    那个string如果是true返回的就是true,否则无论你输入什么都是false
      

  5.   

    Properties p = System.getProperties();
    p.setProperty("test", "true");
    System.out.println("Boolean.getBoolean():" + Boolean.getBoolean("test"));提问:
    setProperty()中设置的"test"和"true",都是什么意思?
      

  6.   

    提问:
    setProperty()中设置的"test"和"true",都是什么意思?-----------------
    设置 [名 - 值] 的对应关系,像Hashtable中的put(Object key, Object value)
      

  7.   

    public static String setProperty(String key,
                                     String value)
    Sets the system property indicated by the specified key. 
    First, if a security manager exists, its SecurityManager.checkPermission method is called with a PropertyPermission(key, "write") permission. This may result in a SecurityException being thrown. If no exception is thrown, the specified property is set to the given value. 
    Parameters:
    key - the name of the system property.
    value - the value of the system property. 
    Returns:
    the previous value of the system property, or null if it did not have one.  
      

  8.   

    设置指定key指示的系统属性。 
    首先,如果有一安全管理器,调用验证方法SecurityManager.checkPermission(key, "write"),可能会可出一个安全异常。
    如果没有抛出异常,用value设置指定的系统属性值。
    返回以前的值或null。
      

  9.   

    设置指定key指示的系统属性,有什么用?
      

  10.   

    设置指定key指示的系统属性,有什么用?
      

  11.   

    设置指定key指示的系统属性,有什么用?
      

  12.   

    设置指定key指示的系统属性,有什么用?
      

  13.   

    Properties p = System.getProperties();
    p.setProperty("test", "true");
    System.out.println("Boolean.getBoolean():" + Boolean.getBoolean(p.getProperty("test").tostring));