This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes convert an array of String to char Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply 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: 24057
    
  13

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
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: convert an array of String to char
 
Similar Threads
String array to arraylist
BufferedReader contents into Array
String to int
Creating an InputStream from a String
Returning byte array to JavaScript from Java applet