Close

Java Collections - Collections.reverse() Examples

Java Collections Java Java API 


Class:

java.util.Collections

java.lang.Objectjava.lang.Objectjava.util.Collectionsjava.util.CollectionsLogicBig

Method:

public static void reverse(List<?> list)

Reverses the order of the elements in the specified list.


Examples


package com.logicbig.example.collections;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class ReverseExample {

public static void main(String... args) {
List<String> list = Arrays.asList("one", "two", "three", "tour");
Collections.reverse(list);
System.out.println(list);
}
}

Output

[tour, three, two, one]




See Also