-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetMaxAgeOfPerson.java
More file actions
52 lines (38 loc) · 1011 Bytes
/
GetMaxAgeOfPerson.java
File metadata and controls
52 lines (38 loc) · 1011 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package com.interview;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
public class GetMaxAgeOfPerson {
private int age;
private String name;
public GetMaxAgeOfPerson(int age, String name) {
super();
this.age = age;
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
return "GetMaxAgeOfPerson [age=" + age + ", name=" + name + "]";
}
public static void main(String[] args) {
List<GetMaxAgeOfPerson> list = new ArrayList<>();
list.add(new GetMaxAgeOfPerson(80, "A"));
list.add(new GetMaxAgeOfPerson(70, "C"));
list.add(new GetMaxAgeOfPerson(90, "B"));
list.add(new GetMaxAgeOfPerson(100, "D"));
GetMaxAgeOfPerson l = list.stream().max(Comparator.comparing(GetMaxAgeOfPerson::getAge)).get();
System.out.println(l);
}
}