JAVA,string 转换成char
时间: 2023-05-17 07:02:30 浏览: 98
数组的方法是什么?
可以使用 string 类的 toCharArray() 方法将一个字符串转换成 char 数组。例如:
String str = "hello world";
char[] charArray = str.toCharArray();
这样就可以将字符串 "hello world" 转换成一个 char 数组了。
相关问题
java中string转换成char
在Java中,可以使用String类的toCharArray()方法将String类型转换为char类型数组。例如:
String str = "Hello World";
char[] charArray = str.toCharArray();
这将把字符串"Hello World"转换为一个char类型的数组,数组中包含每个字符。
java string转换为char数组
可以使用String类的toCharArray()方法将Java字符串转换为char数组。例如:
String str = "Hello World";
char[] charArray = str.toCharArray();
这将把字符串"Hello World"转换为一个char数组,其中charArray[]为'H',charArray[1]为'e',以此类推。
阅读全文
相关推荐
















