这段代码会抛出什么异常:( )
public static void main(String[] args) {
int[] arr = {12,23,43,34,3,6,7,1,9,6};
{
int temp;
for (int i=0; i<arr.length; i++) {
for (int j=0; j<arr.length-i; j++ ) {
if (arr[j] > arr[j+1]) {
temp = arr[j];
arr[j+1] = arr[j];
arr[j+1] = temp;
}
}
}
}
for(int i=0; i<arr.length; i++) {
System.out.print(arr[i] + " ");
}
}NumberFormatException
ArrayIndexOutOfBoundException(数组索引超出边界异常)
IOException
i=0 ==>
for (int j=0; j<arr.length; j++ ) { ==>
if (arr[j] > arr[j+1]) { //j+1越界了
for (int j=0; j<arr.length; j++ ) { ==>
if (arr[j] > arr[j+1]) { //j+1越界了