我正在写一个GUI程序,它有JPasswordField接收来自用户的文本。然后,我用这个如下这个值转换为字符串:为什么toString()为Java中的相同输入返回不同的值?
char[] pass = txtPass.getPassword(); //where txtPass is the JPasswordField
System.out.println("Password:");
////////////////Check password/////
for (int i=0; i< pass.length; i++)
System.out.println(pass[i]);
System.out.println("String pass"+ pass.toString());
不过,凡事我执行应用程序,不同pass.toString的()我会收到。我希望他们是唯一的,以便我可以做更多的crytpgraphy功能。