Privacy Policy Terms Of Use. Copyright © 2006-2010 Java Tutorials and Examples.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
- /*
- * Convert String to char array example. Program to convert String object
- * to array of character.
- */
- public class StringToCharArray {
- public static void main(String args[]){
- String str = "Hello world";
- //to convert string to char array, use toCharArray method of String
- char[] ch = str.toCharArray();
- System.out.println("String converted to char array");
- //print char array
- for(int i=0; i< ch.length; i++)
- System.out.print(ch[i] + " ");
- }
- }

C collect: Graceful couplet
Post new comment