Skip to content

Commit 416e5bf

Browse files
committed
add tostring
1 parent edb5fba commit 416e5bf

File tree

1 file changed

+22
-9
lines changed
  • src/main/java/com/winterbe/java8/samples/lambda

1 file changed

+22
-9
lines changed
Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,29 @@
11
package com.winterbe.java8.samples.lambda;
22

33
/**
4-
* @author Benjamin Winterberg
5-
*/
4+
* @author Benjamin Winterberg
5+
*/
66
public class Person {
7-
public String firstName;
8-
public String lastName;
7+
public String firstName;
8+
public String lastName;
99

10-
public Person() {}
10+
public Person() {
11+
}
12+
13+
public Person(String firstName, String lastName) {
14+
this.firstName = firstName;
15+
this.lastName = lastName;
16+
}
17+
18+
@Override
19+
public String toString() {
20+
StringBuilder builder = new StringBuilder();
21+
builder.append("Person [firstName=");
22+
builder.append(firstName);
23+
builder.append(", lastName=");
24+
builder.append(lastName);
25+
builder.append("]");
26+
return builder.toString();
27+
}
1128

12-
public Person(String firstName, String lastName) {
13-
this.firstName = firstName;
14-
this.lastName = lastName;
15-
}
1629
}

0 commit comments

Comments
 (0)