Person.java 635B

12345678910111213141516171819202122232425262728293031
  1. /**
  2. * Created by leon on 1/24/18.
  3. */
  4. public class Person {
  5. private final String firstName;
  6. private final String lastName;
  7. public Person(String firstName, String lastName) {
  8. this.firstName = firstName;
  9. this.lastName = lastName;
  10. }
  11. public String getFirstName() {
  12. return firstName;
  13. }
  14. public String getLastName() {
  15. return lastName;
  16. }
  17. @Override
  18. public String toString() {
  19. return new StringBuilder()
  20. .append("\nMy first name is " + firstName)
  21. .append("\nMy last name is " + lastName)
  22. .toString();
  23. }
  24. }