Java Utililty Methods Matrix Flip

List of utility methods to do Matrix Flip

Description

The list of methods to do Matrix Flip are organized into topic(s).

Method

int[][]flipInPlace(int[][] theArray)
returns the flipping of entire block/piece
for (int i = 0; i < (theArray.length / 2); i++) {
    int[] temp = theArray[i];
    theArray[i] = theArray[theArray.length - i - 1];
    theArray[theArray.length - i - 1] = temp;
return theArray;
int[][]flipLeftToRight(int[][] theArray)
flip the block from left to right
for (int i = 0; i < theArray.length; i++) {
    for (int curr = 0; curr < (theArray[0].length + 1) / 2; curr++) {
        int saved = theArray[i][curr];
        theArray[i][curr] = theArray[i][theArray[0].length - 1 - curr];
        theArray[i][theArray[0].length - 1 - curr] = saved;
return theArray;
...
int[][]flipLR(int[][] x)
flip LR
int[][] x2 = new int[x.length][x[0].length];
for (int i = 0; i < x.length; i++) {
    for (int j = 0; j < x[0].length; j++) {
        x2[i][j] = x[i][x[0].length - j - 1];
return x2;
voidflipOverX(T[][] arr)
Flips 2D Array as if around a Horizontal Axis.
int z = arr.length - 1;
for (int a = 0; a < z; a++) {
    T[] tmp = arr[a];
    arr[a] = arr[z];
    arr[z] = tmp;
voidflipOverY(T[][] arr)
Flips the 2D Array as if around a Vertical Axis.
for (int i = 0; i < arr.length; i++) {
    flipOverY(arr[i]);