标签:转换 har string dem char 字符数组 new demo length
public class StringAPIDemo1 {
public static void main(String[] args) {
String str = "HELLO";
char c[] = str.toCharArray(); // 将字符串变为字符数组
for (int i = 0; i < c.length; i++) {
System.out.print(c[i] + "\t");
}
System.out.println(); //换行
String str2 = new String(c);// 将整个字符数组转换为字符串
String str3 = new String(c, 0, 3);// 将部分字符数组转换为字符串
System.out.println(str2);
System.out.println(str3);
}
}
标签:转换 har string dem char 字符数组 new demo length
原文地址:https://www.cnblogs.com/wangffeng293/p/13293293.html