Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Seperating a string and storing as a char

Status
Not open for further replies.

MSB18

Programmer
Nov 2, 2001
5
GB
How do you seperate a string such as "ABCDEFG" in to "A","B" etc and store each letter as a character, i know you can seperate the string as follows:

String s="ABCD";
String s1= s.substring(0,1);
String s2= s.substring(1,2);
//etc..

//and you have
s1=A
s2=B
//etc
but how do you store them as chars?????

thank you in advance


 
How about:
Code:
String s = "ABCD";
char[] charArray = s.toCharArray();
Check the Javadocs for String if you want more information.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top