Online Java Compiler By
JavaTpoint.com
import java.util.*; public class CollectionsReverseExample2 { public static void main(String[] args) { //Create a list of Integer List
mylist = new ArrayList
(); mylist.add(1); mylist.add(2); mylist.add(3); mylist.add(4); System.out.println("Original List:- " + mylist); Collections.reverse(mylist); System.out.println("Modified List:- " + mylist); } }
Output