Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Created by Julio Tentor <jtentor@fi.unju.edu.ar>
- //
- import java.lang.Comparable;
- public class Person implements Comparable<Person> {
- private String lastname;
- private String firstname;
- public Person() {
- this("", "");
- }
- public Person(String lastname, String firstname) {
- this.lastname = lastname;
- this.firstname = firstname;
- }
- @Override
- public String toString() {
- return this.lastname + ", " + this.firstname;
- }
- @Override
- public int compareTo(Person o) {
- return this.toString().compareTo(o.toString());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement