Search This Blog

Monday, September 17, 2018

Java String toCharArray() method example


  1. public class StringToCharArrayExample{  
  2. public static void main(String args[]){  
  3. String s1="hello";  
  4. char[] ch=s1.toCharArray();  
  5. for(int i=0;i<ch.length;i++){  
  6. System.out.print(ch[i]);  
  7. }  
  8. }}  
Output:
hello