wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes convert an array of String to char Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "convert an array of String to char" Watch "convert an array of String to char" New topic
Author

convert an array of String to char

Grant Allen
Greenhorn

Joined: Jun 04, 2006
Posts: 8
How can I convert a String from a String array into an array of chars?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Your subject line and your message both seem to say different things, and I'm guessing what you're really asking is yet another, third thing: how to turn a single String into an array of char. That's an easy one -- the String class has a single method toCharArray() that does it:

String myString = "Hello";
char[] theCharArray = myString.toCharArray();


[Jess in Action][AskingGoodQuestions]
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
if you are asking how to convert a String (not a String[]) to an array of characters

have a look at the api docs for the String class
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html

scroll down to the methods (particularly the ones starting to...)
Grant Allen
Greenhorn

Joined: Jun 04, 2006
Posts: 8
thanks
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: convert an array of String to char