forked from ayonious/Java-Best-Practices-Java8
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPerson.java
More file actions
48 lines (36 loc) · 851 Bytes
/
Person.java
File metadata and controls
48 lines (36 loc) · 851 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
package lamda.Example7;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
public class Person {
private String surName;
private int age;
private String gender;
public Person(String sur, int ag) {
surName = sur;
age = ag;
gender = "Male";
}
public void printName() {
System.out.println(surName);
}
public String printCustom(Function<Person, String> f) {
return f.apply(this);
}
public static List<Person> createShortList() {
List<Person> people = new ArrayList<>();
people.add(new Person("z", 16));
people.add(new Person("x", 17));
people.add(new Person("c", 18));
return people;
}
public String getSurName() {
return surName;
}
public int getAge() {
return age;
}
public String getGender() {
return gender;
}
}