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