标签:从零开始 图片 数组 other char case exce pre lang
程序出现了以下报错是什么原因呢?
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 5
at case50.Case07.main(Case07.java:25)
是数组越界了
for (int i = 0; i <= ch.length; i++) { //数组角标从零开始,在这里应为 i < ch.length
if (ch[i] >= '0' && ch[i] <= '9') {
digital++;
} else if ((ch[i] >= 'a' && ch[i] <= 'z') || (ch[i] >= 'A' && ch[i] <= 'Z')) {
character++;
} else if (ch[i] == ' ') {
blank++;
} else {
other++;
}
}
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 数组越界
标签:从零开始 图片 数组 other char case exce pre lang
原文地址:https://www.cnblogs.com/YanJieMao/p/12368746.html