在Java中有SortedSet和SortedMap接口.两者都属于Java的标准集合框架,并提供了一种访问元素的排序方式.
但是,根据我的理解SortedList,Java中没有.您可以使用java.util.Collections.sort()对列表进行排序.
知道为什么它的设计是这样的吗?
我有以下课程:
class Data {
String systemId;
String fileName;
int x;
int y;
Data(String systemId, String fileName, int x, int y) {
this.systemId = systemId;
this.fileName = fileName;
this.x = x;
this.y = y;
}
public String getSystemId() {
return systemId;
}
public void setSystemId(String systemId) {
this.systemId = systemId;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = …Run Code Online (Sandbox Code Playgroud)