Here you can find the source of reverse(List
public static <T> List<T> reverse(List<T> list)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.Collections; import java.util.List; public class Main { public static void reverse(long a[], int b, int e) { if (!(b <= e)) { throw new IllegalArgumentException("Wrong begin & end"); }// www . j a v a 2 s .c o m for (; b < e; ++b, --e) { long t = a[b]; a[b] = a[e]; a[e] = t; } } public static void reverse(long a[]) { reverse(a, 0, a.length - 1); } public static void reverse(int a[], int b, int e) { if (!(b <= e)) { throw new IllegalArgumentException("Wrong begin & end"); } for (; b < e; ++b, --e) { int t = a[b]; a[b] = a[e]; a[e] = t; } } public static void reverse(int a[]) { reverse(a, 0, a.length - 1); } public static void reverse(byte a[], int b, int e) { if (!(b <= e)) { throw new IllegalArgumentException("Wrong begin & end"); } for (; b < e; ++b, --e) { byte t = a[b]; a[b] = a[e]; a[e] = t; } } public static void reverse(byte a[]) { reverse(a, 0, a.length - 1); } public static <T> List<T> reverse(List<T> list) { List<T> nlist = new ArrayList<T>(list); Collections.reverse(nlist); return nlist; } }