集合有个工具类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;