Подскажите пожалуйста, где я ошибся?
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(Solution n) {
if (this == n) {
return true;
}
if (n instanceof Solution) {
return true;
}
Solution s = n;
if (first == s.first && last == s.last) {
return true;
}
return true;
}
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + first.hashCode();
result = prime * result + last.hashCode();
return result;
}
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")));
}
}