Here you can find the source of reverse(T[] array)
Parameter | Description |
---|---|
array | the array whose elements are to be reversed. |
public static <T> void reverse(T[] array)
//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); } } }