This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft 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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
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: 24168
    
  30

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://aspose.com/file-tools
 
subject: convert an array of String to char
 
Similar Threads
Creating an InputStream from a String
Returning byte array to JavaScript from Java applet
String to int
BufferedReader contents into Array
String array to arraylist