Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to convert char array to string

807591Jun 4 2008 — edited Jun 4 2008
sirs,

i have written a method in java which will return a randomly generated string of a fixed length. i am creating one one character and inserting it into char array.

at last i am converting it to string
like this
String newpass= pass.toString();// pass is a char array
but problem is that the string is having different value what i hav generated.

if i am doing like this..
String newpass= new String(pass);// pass is a char array
here newpass is having correct value but having some error
error in the sense when i print
System.out.println(newpass+"some text");
"some text" is not printing

can you suggest the better way
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 2 2008
Added on Jun 4 2008
11 comments
394 views