for 和 foreach 怎么打印出来不一样的,求教 下面是代码:两个打印出来不一样 public class TestString03 { public static void main(String[] args) { String str = "Hello World"; char[] c = str.toCharArray(); for (int i = 0; i < c.length; i++) { System.out.print(c[i] + ","); } } //这个打印出来的是一组数字类型的数组
public class TestString03 { public static void main(String[] args) { String str = "Hello World"; char[] c = str.toCharArray(); for (int i : c) { System.out.print(i + ","); }
} //这个打印出来是正常的字符数组,
------解决方案--------------------
for (int i : c) ===>for (char i : c)