How to reverse elements of given one-dimensional and two dimenional arrays

Below is the complete solution for the APCS problem where for a given matrix, how can you operations such as reverseArray of single dimension array, reverseAllRows and reverseMatrix of a given two dimensional array.

Solution for problem1: BAR7APCS1
public class ArrayUtil {		
	//Solution for problem 1(a)
	public static void reverseArray(int[] arr) {
		for (int i = 0; i < arr.length/2; i++) {
			int temp = arr[i];
			arr[i] = arr[arr.length-1 - i];
			arr[arr.length-1 - i] = temp;
		}
	}
}

public class Matrix {

	private int[][] mat;

	public Matrix(int[][] mat) {
		this.mat = mat;
	}

        //Solution for problem  1(b)
	public void reverseAllRows() {
		for (int i = 0; i < mat.length; i++) {
			ArrayUtil.reverseArray(mat[i]);
		}
	}

	//Solution for problem  1(c)
	public void reverseMatrix() {
		reverseAllRows();
		for (int i = 0; i < mat.length / 2; i++) {
			int temp[] = mat[i];
			mat[i] = mat[mat.length - 1 - i];
			mat[mat.length - 1 - i] = temp;
		}
	}

	

}

//Testing the code
public class BAR7APCS1Problem1 {

	public static void main(String[] args) {

		int arr[] = { 2, 7, 5, 1, 0 };
		
		ArrayUtil.reverseArray(arr);
		
		for (int i : arr) {
			System.out.print(i + " ");
		}
		
		int a[][] = {
				{1, 2, 3, 4},
				{5, 6, 7, 8},
				{9, 10, 11, 12}
		};
		
		Matrix m = new Matrix(a);
		
		System.out.println("\n--------------");
		
		m.reverseAllRows();
		
		for (int[] is : a) {
			for (int i : is) {
				System.out.print(i + " ");
			}
			System.out.println();
		}
		
		System.out.println("\n--------------");
		
		int b[][] = {
				{1, 2},
				{3, 4},
				{5, 6}
		};
		
		m = new Matrix(b);
		
		m.reverseMatrix();
		
		for (int[] is : b) {
			for (int i : is) {
				System.out.print(i + " ");
			}
			System.out.println();
		}
	}
}