我有简单的课程
public class ActiveAlarm {
public long timeStarted;
public long timeEnded;
private String name = "";
private String description = "";
private String event;
private boolean live = false;
}
Run Code Online (Sandbox Code Playgroud)
和List<ActiveAlarm>con.如何按升序排序timeStarted,然后按timeEnded?有人可以帮忙吗?我知道在C++中使用泛型算法和重载运算符<,但我是Java的新手.
public class Product implements Serializable{
private String id;
private String name;
private double price ;
private int quantity;
public Product(String id, String name, double price, int quantity) {
this.id = id;
this.name = name;
this.price = price;
this.quantity = quantity;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getPrice() {
return price;
} …Run Code Online (Sandbox Code Playgroud)