我要求我没有得到直接答案,而是提示我继续学习。
我的任务是创建一个数组>填充它>排序>打印未分类和排序。
我要么最终得到一个满是最低数字的arrayList,要么我遇到错误:
线程中的异常" main" java.lang.ArrayIndexOutOfBoundsException
for (int index = 0; index <= 29; index ++){
System.out.println(" I have reached the first ForLoop Sort " + index);
for (int i = 0 ; i <= midSortArray.size(); i++){
System.out.println(" I have reached the Second ForLoop Sort " + i);
if(currentInteger <= midSortArray.get(i)){
System.out.println(" If is true ");
currentInteger = midSortArray.get(i);
} else {
System.out.println("If is false");
lowestInteger = currentInteger;
sortedArray.add(0, lowestInteger);
midSortArray.remove(midSortArray.indexOf(lowestInteger));
System.out.println(sortedArray);
}
}
}