Java List reverse elements

Description

Java List reverse elements

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

public class Main {
  public static void main(String args[]) {
    List<String> langList = new ArrayList<>();
    langList.add("CSS");
    langList.add("HTML");
    langList.add("Java");
    langList.add("Javascript");
    langList.add("C++");
    langList.add("Java");
    langList.add("SQL");
    Comparator<String> comp = Collections.reverseOrder();

    System.out.println(langList);
    Collections.sort(langList,comp);
    System.out.println(langList);
  }/*www  .  j a va  2  s.c o m*/
}



PreviousNext

Related