Java List Reverse reverse(final List list)

Here you can find the source of reverse(final List list)

Description

Reverse a list.

License

Open Source License

Parameter

Parameter Description
list The <code>List</code> to reverse.

Declaration

public static <T> void reverse(final List<T> list) 

Method Source Code

//package com.java2s;
/**//w  ww  .  j  a  v  a 2  s  . c  om
 *  Copyright (C) 2002-2015   The FreeCol Team
 *
 *  This file is part of FreeCol.
 *
 *  FreeCol is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  FreeCol is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with FreeCol.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.util.List;

public class Main {
    /**
     * Reverse a list.
     *
     * @param list The <code>List</code> to reverse.
     */
    public static <T> void reverse(final List<T> list) {
        final int len = list.size();
        if (len <= 0)
            return;
        for (int i = 0, j = len - 1; i < j; i++, j--) {
            T t = list.get(i);
            list.set(i, list.get(j));
            list.set(j, t);
        }
    }
}

Related

  1. listToArrowSep(List strings, String highlightFirst, String highlightSecond, boolean reversed)
  2. reverse(Collection list)
  3. reverse(final List list)
  4. reverse(final List a)
  5. reverse(final List l)
  6. reverse(final List list)
  7. reverse(final List list)
  8. reverse(final List list)
  9. reverse(final List strings)