4

Is there any function to do this kind of job or do one have to parse each char and add it to the array?

4 Answers 4

15

Use String#toCharArray().

char[] chars = "some string".toCharArray();
1
  • 3
    Damn! 14 seconds! +1 because I don't want to be a sore loser :-) Apr 27, 2011 at 13:05
4
"read java docs".toCharArray();
1

Use the String.toCharArray() method.

0

Use the String.getChars() method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.