L10.4: ArrayList Reverse

PHOTO EMBED

Wed Oct 18 2023 13:30:24 GMT+0000 (Coordinated Universal Time)

Saved by @testpro #java

import java.util.ArrayList;
import java.util.List;
import java.util.Collections;

public class Main {
    public static void main(String[] args) {

        List<String> koelPages = new ArrayList<>();

        koelPages.add("LoginPage");
        koelPages.add("HomePage");
        koelPages.add("ProfilePage");
        koelPages.add("APage");
        koelPages.add("ZPage");

        Collections.sort(koelPages);
        Collections.reverse(koelPages);
        System.out.println(koelPages);
    }
}
// Output: [ZPage, ProfilePage, LoginPage, HomePage, APage]
content_copyCOPY