public class ConvIntArray {
public static void main(String[] args) {
Integer is[] = {49, 72, 86, 45, 66, 59};
String[] ss = new String[is.length];
for (Integer i : is) {
ss[i] = Integer.toString(i);
}
}
}
运行总是出Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 49
at ConvIntArray.main(ConvIntArray.java:9)这个错误
------解决思路----------------------
is.length是6,所以数组SS的长度是6。你把is赋值给i,i取到的第一个元素是49,ss[49]肯定爆掉了。估计你想把is的下标赋值给i,对吗?