Java List Reverse toReverse(List list)

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

Description

to Reverse

License

Apache License

Declaration

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

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.ArrayList;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

public class Main {
    public static <T> List<T> toReverse(List<T> list) {
        List<T> ret = new ArrayList<>(list.size());
        for (Iterator<T> itr = new LinkedList<>(list).descendingIterator(); itr.hasNext();) {
            T obj = itr.next();/*from w w  w. j av  a2 s . c  om*/
            ret.add(obj);
        }
        return ret;
    }
}

Related

  1. reverseUseList(int[] values)
  2. reverseVector(List vector)
  3. sortListBySublistSizeThenHead(List> list, boolean reverseOrder)
  4. sortReverse(List list)
  5. sortReverseOrder(List list)