diff --git a/classpath/java/util/Collections.java b/classpath/java/util/Collections.java index f6af29ae9b..23db1872ac 100644 --- a/classpath/java/util/Collections.java +++ b/classpath/java/util/Collections.java @@ -164,6 +164,15 @@ public class Collections { return -1 - right; } + public static void reverse(List list) { + int ascending = 0, descending = list.size() - 1; + while (ascending < descending) { + T tmp = list.get(ascending); + list.set(ascending++, list.get(descending)); + list.set(descending--, tmp); + } + } + static T[] toArray(Collection collection, T[] array) { Class c = array.getClass().getComponentType();