Java List Reverse reversed(List l)

Here you can find the source of reversed(List l)

Description

A reversed copy of the given list

License

Apache License

Parameter

Parameter Description
T The type of the items in the list
l The list to reverse

Return

The list, reversed

Declaration

public static <T> List<T> reversed(List<T> l) 

Method Source Code

//package com.java2s;
/*/*w  w w  .ja  v a  2s  . c  o m*/
 * Copyright 2008-2009 LinkedIn, Inc
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

import java.util.ArrayList;

import java.util.Collections;

import java.util.List;

public class Main {
    /**
     * A reversed copy of the given list
     * 
     * @param <T> The type of the items in the list
     * @param l The list to reverse
     * @return The list, reversed
     */
    public static <T> List<T> reversed(List<T> l) {
        List<T> copy = new ArrayList<T>(l);
        Collections.reverse(copy);
        return copy;
    }
}

Related

  1. reverse(List l)
  2. reverseCopy(Iterable list)
  3. reverseCopy(List list)
  4. reverseCopy(List original)
  5. reversed(final List list)
  6. reversed(List list)
  7. reversedCopy(List src, List dest)
  8. reverseIterable(final List list)
  9. reverseIterator(final List list)