№3 я понимаю почему валится валидатором - ожидается использование instanceOf. Об этом в требованиях ни слова и моя реализация - одна из двух допустимых. Она режет сабклассы, но корректно утверждает, что А = А, а не А = (А) В.
Update:
public class Solution {
private final String first, last;
public Solution(String first, String last) {
this.first = first;
this.last = last;
}
public boolean equals(Object n) {
if (this == n) return true;
if (n == null || !(n instanceof Solution)) return false;
Solution tmp = (Solution) n;
return Objects.equals(this.first, tmp.first) && Objects.equals(this.last, tmp.last) ;
}
public int hashCode() {
int result = 1;
result = result + ((first == null) ? 0 : first.hashCode());
result = result + ((last == null) ? 0 : last.hashCode());
return result;
}
public static void retrieveValuesFromListMethod2(Set set, Solution n)
{
Enumeration e = Collections.enumeration(set);
while(e.hasMoreElements())
{
System.out.println(e.nextElement().hashCode());
}
}