Java Array Flip flip(T[] array)

Here you can find the source of flip(T[] array)

Description

flip

License

Open Source License

Declaration

public static <T> T[] flip(T[] array) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static <T> T[] flip(T[] array) {
        T[] tmp = array.clone();/*  ww  w .j av  a 2 s.  c o m*/
        for (int i = 0; i < array.length; i++) {
            tmp[i] = array[array.length - i];
        }
        return tmp;
    }

    public static byte[] flip(byte[] array) {
        byte[] tmp = array.clone();
        for (int i = 0; i < array.length; i++)
            tmp[i] = array[array.length - 1];
        return tmp;
    }
}

Related

  1. flip(String[][] data)
  2. flipAllBits(byte[] bytes)
  3. flipAllBitsInPlace(byte[] bytes)
  4. flipChessboardVertically(int[] chessboard)