Java Utililty Methods List Reverse

List of utility methods to do List Reverse

Description

The list of methods to do List Reverse are organized into topic(s).

Method

Listreverse(Collection list)
Returns a list that contains the elements of the specified list in reversed order.
ArrayList<T> reversed = new ArrayList<T>(list);
Collections.reverse(reversed);
return reversed;
Iterablereverse(final List list)
reverse
return new Iterable<E>() {
    @Override
    public Iterator<E> iterator() {
        final ListIterator<E> it = list.listIterator(list.size());
        return new Iterator<E>() {
            @Override
            public boolean hasNext() {
                return it.hasPrevious();
...
ArrayListreverse(final List a)
Reverse order of elements in a list.
ArrayList<T> r = new ArrayList<T>();
for (int i = a.size() - 1; i >= 0; i--) {
    r.add(a.get(i));
return r;
Listreverse(final List l)
reverse
final List<T> newL = new ArrayList<T>(l);
Collections.reverse(newL);
return newL;
Listreverse(final List list)
reverse
Collections.reverse(list);
return list;
Iterablereverse(final List list)
reverse
return new Iterable<T>() {
    @Override
    public Iterator<T> iterator() {
        final ListIterator<T> listIter = list.listIterator(list.size());
        return new Iterator<T>() {
            @Override
            public boolean hasNext() {
                return listIter.hasPrevious();
...
Listreverse(final List list)
reverse
final ArrayList<T> result = new ArrayList<>(list);
Collections.reverse(result);
return result;
voidreverse(final List list)
Reverse a 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);
Listreverse(final List strings)
reverse
final LinkedList<T> result = new LinkedList<T>();
for (final T s : strings) {
    result.addFirst(s);
return Collections.unmodifiableList(result);
Listreverse(List aList)
Reverses the items in the given list.
for (int i = 0, max = aList.size(), iMax = max / 2; i < iMax; i++) {
    int oppositeIndex = max - i - 1;
    Object original = aList.set(i, aList.get(oppositeIndex));
    aList.set(oppositeIndex, original);
return aList;