集合有个工具类Collections,直接调用其静态方法,对集合排序反转:
比如有个集合:
List list =...
反转排序方法:
Collections.reverse(list);

================================================

方法:实现Comparable接口排序package collsort.comparable;
package com.cvicse.sort.comparable;

public class Cat implements Comparable<Cat> {
private int age;
private String name;

public Cat(int age, String name) {
this.age = age;
this.name = name;
}

public int getAge() {
return age;

相关文章:

  • 2022-12-23
  • 2021-04-07
  • 2022-12-23
猜你喜欢
  • 2021-05-14
相关资源
相似解决方案