我是Java的新手,我正在尝试使用Lambda表达式和Comparators.我有这个公共类Person与其他getter和toString方法:
public class Person {
private String name;
private int age;
private int computers;
private double salary;
public Person(String name, int age, int computers, double salary){
this.name = name;
this.age = age;
this.computers = computers;
this.salary = salary;
}
public String getName(){
return this.name;
}
public int getAge(){
return this.age;
}
public int getComputers(){
return this.computers;
}
public double getSalary(){
return this.salary;
}
@Override
public String toString(){
return "Name: " + getName() + ", age: "+ getAge() +
", N° …Run Code Online (Sandbox Code Playgroud)