Tuesday, March 1, 2011

String to Character array

In java it is very easy to convert a String in to char array
String str = "Go ahead.";
char[] cArray = str.toCharArray();
System.out.println("Size = " + cArray.length);
for (char c : cArray){
System.out.println(c);
}
Run this code and note that the character and the full-stop character are also included in the char array.

No comments:

Post a Comment