/*
Convert String to Character Array Example
This example shows how to convert a given String object to an array
of character
*/
public class StringToCharacterArrayExample {
public static void main(String args[]){
//declare the original String object
String strOrig = "Hello World";
//declare the char array
char[] stringArray;
//convert string into array using toCharArray() method of string class
stringArray = strOrig.toCharArray();
//display the array
for(int index=0; index < stringArray.length; index++)
System.out.print(stringArray[index]);
}
}
/*
Output of the program would be :
Hello World
*/
Bookmark/Search this post with:
Thank you. Your code snippet
Thank you. Your code snippet is very useful.
thank you very, much it
thank you very, much it helped me constructing something similar to c atoi in java.
2D char array?
How do you convert a String to a 2D character array?
Thanks a lot
Its great code..
Rahul
ila
thanks a lot buddy......
Post new comment