Java String toCharArray() 方法示例


Java String toCharArray() 方法示例

import java.lang.*;

public class StringDemo {

   public static void main(String[] args) {

      // converts String value to character array type value

      String str = " Java was developed by James Gosling";

      char retval[] = str.toCharArray();



      // displays the converted value

      System.out.println("Converted value to character array = ");

      System.out.println(retval);

   }

}