Java tochararray() method: converts a string into a character array

tocharArray()

Example

public static void main(String[] args){
    String strCom = "JAVA编程词典";  //定义字符串
    char[] str = strCom.tocharArray();  //将字符串转换成数组
    for(int i=0;i<str.length;i++){  //输出返回数组
    System.out.println(str[i]);
  }
}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>