Here you can find the source of reverse(List aList)
public static List reverse(List aList)
//package com.java2s; import java.util.*; public class Main { /**//from w ww . j a v a 2s . c o m * Reverses the items in the given list. */ public static List reverse(List aList) { 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; } /** * Returns the size of a list (accepts null list). */ public static int size(List aList) { return aList == null ? 0 : aList.size(); } /** * Returns the object at the given index (returns null object for null list or invalid index). */ public static <T> T get(List<T> aList, int anIndex) { return aList == null || anIndex < 0 || anIndex >= aList.size() ? null : aList.get(anIndex); } }