集合顺序翻转

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

posted @ 2019-06-25 17:07  xiaoshen666  阅读(636)  评论(0编辑  收藏  举报