Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

convert an array of String to char

 
Grant Allen
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I convert a String from a String array into an array of chars?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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();
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic