Подскажите в чем ошибка?
package com.javarush.task.task21.task2104;
import java.util.HashSet;
import java.util.Set;
/*
Equals and HashCode
*/
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(n==this){
return true;
}
if(n instanceof Solution){
Solution sol = (Solution) n;
if(this.first!=null&&this.last!=null&&sol.first!=null&&sol.last!=null){
if(sol.first.equals(this.first)&&sol.last.equals(this.last)){
return true;
}
else return false;
}
else return false;
}
else return false;
}
public int hashCode() {
int a;
if(first == null){
a = 0;
}
else {
a = first.hashCode();
}
int b;
if(last == null){
b = 0;
}
else {
b = last.hashCode();
}
return 31 * a + b;
}
public static void main(String[] args) {
Set<Solution> s = new HashSet<>();
s.add(new Solution("Donald", "Duck"));
System.out.println(s.contains(new Solution("Donald", "Duck")));
}
}