question #14
Closed
SinaRahimii75
started this conversation in
General
Replies: 2 comments
-
Answer is 2 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
import java.util.*;
class Human{
int kindness;
int money;
public Human(int kindness, int money) {
this.kindness = kindness;
this.money = money;
}
}
public class Containers {
public static void main(String[] args) {
List list = Arrays.asList(new Human(1, 10), new Human(5, 2));
Comparator comparator = new Comparator(){
@OverRide
public int compare(Human o1, Human o2) {
return o1.kindness<o2.kindness?-1:o1.kindness==o2.kindness?0:+1;
}
};
System.out.println(Collections.max(list, comparator).money);
}
}
Beta Was this translation helpful? Give feedback.
All reactions