package com.heim.bean;
public class AAA {
/**
* @param args
*/
public static void main(String[] args) {
int[][] arr = { { 11, 22, 33, 44, 55 }, { 55, 22, 33, 66 },
{ 99, 88, 77 } };
reverse(arr);
print(arr);
}
public static void reverse(int[][] arr) {
for (int i = 0; i < arr.length / 2; i++) {
for (int j = 0; j < arr.length / 2; j++) {
int x = arr[j];
arr[j] = arr[arr.length - 1 - i][arr[arr.length - 1 - i].length
- i];
arr[arr.length - 1 - i][arr[arr.length - 1 - i].length - 1 - i] = x;
}
}
}
public static void print(int[][] arr) {
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr.length; j++) {
System.out.println(arr[j]);
}
}
}
}
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3
at com.heim.bean.AAA.reverse(AAA.java:20)
at com.heim.bean.AAA.main(AAA.java:11)
|
|