-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathPerson.java
More file actions
38 lines (31 loc) · 905 Bytes
/
Person.java
File metadata and controls
38 lines (31 loc) · 905 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
public class Person implements Cloneable {
private String firstName;
private String lastName;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
@Override
public String toString() {
return "Person{" +
"firstName='" + firstName + '\'' +
", lastName='" + lastName + '\'' +
'}';
}
/**
* Overridden to make it public. Always call super.clone(). Makes a shallow copy. OK in this case because all
* instance variables are immutable.
*/
@Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
}