集合顺序翻转
集合有個(gè)工具類Collections,直接調(diào)用其靜態(tài)方法,對(duì)集合排序反轉(zhuǎn):
比如有個(gè)集合:
List list =...
反轉(zhuǎn)排序方法:
Collections.reverse(list);
================================================
方法:實(shí)現(xiàn)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;
轉(zhuǎn)載于:https://www.cnblogs.com/xiaoshen666/p/11083913.html
總結(jié)
- 上一篇: 吉林省农业农村厅网站官网
- 下一篇: go json