Java List Reverse reverse(List list)

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

Description

Method to reverse the list

License

Open Source License

Parameter

Parameter Description
list a parameter

Return

List

Declaration

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

Method Source Code


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

import java.util.ArrayList;

import java.util.List;

public class Main {
    /**/*from  w ww. j av a2 s.c  o  m*/
     * Method to reverse the list
     * 
     * @param list
     * @return {@link List<T>}
     */
    public static <T> List<T> reverse(List<T> list) {
        if (list != null && list.size() > 0) {
            List<T> updatedList = new ArrayList<>();
            for (int i = list.size() - 1; i >= 0; i--) {
                updatedList.add(list.get(i));
            }
            return updatedList;
        }
        return null;
    }
}

Related

  1. reverse(List list)
  2. reverse(List list)
  3. reverse(List a)
  4. reverse(List l)
  5. reverse(List list)
  6. reverse(List list)
  7. reverse(List list)
  8. reverse(List list)
  9. reverse(List list)

  10. HOME | Copyright © www.java2s.com 2016