Tre*_*vor 1 java sorting arraylist
我有一个我创建的类的实例的ArrayList,每个实例都包含一个带字符串的字段.我在我创建的类中实现了Comparable.如何对数组列表进行排序?
编辑
没有错误给我
class Gene {
}
class MyGene extends Gene implements Comparable<MyGene> {
public int compareTo(MyGene o) {
throw new UnsupportedOperationException("Method is not implemented yet.");
}
}
Run Code Online (Sandbox Code Playgroud)
...
List<MyGene> l = new ArrayList<MyGene>();
Collections.sort(l);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5028 次 |
最近记录: |