How to convert char [] to String ?

Hi

i created a login form ...

while entering username or password field may left blank program counts length a shows warnings....

But...textfield is ok...

But passsword field carrys char[]..

How can i convert it to string or is any other ideas possible...

String lengthtextfield = textfield.getText();//textfield is JTextFields object

char [] lengthpasswordfield = passwordfield.getPassword();//passwordfield is JPasswordFields object //password field

//fill username //its ok --works

if(lengthtextfield.length() == 0)

{

JOptionPane.showMessageDialog(null,"Enter username !!!","Username", JOptionPane.ERROR_MESSAGE);

return;

}

//fill password //but here comes problem

if(lengthpasswordfield.length() == 0)

{

JOptionPane.showMessageDialog(null,"Enter password !!!","Password", JOptionPane.ERROR_MESSAGE);

return;

}

Would anybody please tell me how can i solve this....

[1494 byte] By [Reona] at [2007-11-27 1:55:27]
# 1
constructor String(char[] value) does exist, so you just have to do:String passwordAsString = new String(passwordField.getPassword());
calvino_inda at 2007-7-12 1:28:25 > top of Java-index,Java Essentials,Java Programming...
# 2
Thanks for your help...
Reona at 2007-7-12 1:28:25 > top of Java-index,Java Essentials,Java Programming...
# 3
*Sigh*Remember the whole point to getPassword returning a char[] is so that you can *avoid* creating a String. You might as well call getText.
DrLaszloJamfa at 2007-7-12 1:28:25 > top of Java-index,Java Essentials,Java Programming...