Click here to Skip to main content
15,890,690 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Java
char password = userPass.getPassword();
String Box2 = Character.toString(password);


this method gives me an error?

tell me a correct way to convert char from passwordfield and convert it to string?
Posted

Try with this code:
Java
String passText = new String(userPass.getPassword());
 
Share this answer
 
v2
Try this code:
char[] password = userPass.getPassword();
String passwordString = new String(password);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900