Java Array Reverse reverse(T[] array)

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

Description

Reverses the order of the elements in the specified array.

License

Open Source License

Parameter

Parameter Description
array the array whose elements are to be reversed.

Declaration

public static <T> void reverse(T[] array) 

Method Source Code

//package com.java2s;
/**********************************************************************
 * Copyright (c) 2005-2009 ant4eclipse project team.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:// w ww.  j a v a 2 s  .c o m
 *     Nils Hartmann, Daniel Kasmeroglu, Gerd Wuetherich
 **********************************************************************/

import java.util.Arrays;
import java.util.Collections;

import java.util.List;

public class Main {
    /**
     * Reverses the order of the elements in the specified array.
     * 
     * @param array
     *          the array whose elements are to be reversed.
     */
    public static <T> void reverse(T[] array) {
        if (array != null) {
            final List<T> list = Arrays.asList(array);
            Collections.reverse(list);
        }
    }
}

Related

  1. arrayReverse(Object[] array)
  2. arrayReverse(T[] array)
  3. ArraysReverse(byte[] array)
  4. getReverseOffsets(long fileLength, long position, byte[] buffer, int size)
  5. reverse(T[] array)
  6. reverse(T[] array)
  7. reverse(T[] array)
  8. reverse(T[] array)
  9. reverse(T[] originalArray)