fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. /* Name of the class has to be "Main" only if the class is public. */
  6. class Ideone
  7. {
  8. public static void main (String[] args)
  9. {
  10.  
  11. //declare the original String object
  12. String strOrig = "Hello";
  13. //declare the char array
  14. char[] stringArray;
  15.  
  16. //convert string into array using toCharArray() method of string class
  17. stringArray = strOrig.toCharArray();
  18.  
  19. //display the array
  20. for(int index=0; index < stringArray.length; index++){
  21. System.out.print(stringArray[index]);
  22. }
  23.  
  24. }
  25. }
Success #stdin #stdout 0.04s 4386816KB
stdin
hello
stdout
Hello