提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
使用方法排序的比较器对象。
import java.util.List; import java.util.Arrays; import java.util.Collections;/**nowjava.com - 时 代 Java**/ public class Main { public static void main(String[] args) { String[] suits = {"Hearts", "Diamonds", "Clubs", "Spades"}; // Create and display a list containing the suits array elements List<String> list = Arrays.asList(suits); // create List System.out.printf("Unsorted array elements: %s%n", list); // sort in descending order using a comparator Collections.sort(list,