JPasswordField passwdField = new JPasswordField();1.String passwd = passwdField.getPassword().toString().trim();2.String passwd = String.valueOf(passwdField.getPassword());为什么第一个是“乱码”,而第二个可以正常显示呢?java JPasswordField

解决方案 »

  1.   

    getPasswordpublic char[] getPassword()
    Returns the text contained in this TextComponent. If the underlying document is null, will give a NullPointerException. For stronger security, it is recommended that the returned character array be cleared after use by setting each character to zero.人家返回的是一个char数组,你还tostring