集合顺序翻转
集合有個工具類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;
轉載于:https://www.cnblogs.com/xiaoshen666/p/11083913.html
總結
- 上一篇: 吉林省农业农村厅网站官网
- 下一篇: go json