When you add instances of the given Person class in a HashSet, the resulting hash set is too large. Evidently, duplicates are not found. Remedy this problem by implementing the equals and hashCode methods.

Complete the following file:

Person.java

import java.util.Set; import java.util.HashSet; public class Person { private String firstName; private String lastName; public Person(String firstName, String lastName) { this.firstName = firstName; this.lastName = lastName; } public String toString() { return lastName + "/" + firstName; } // This method is used to check your work public static int check(String[] names) { Set<Person> result = new HashSet<Person>(); for (int i = 0; i < names.length; i += 2) { Person p = new Person(names[i], names[i + 1]); result.add(p); } return result.size(); } }