я просто не понимаю, что конкретно от меня требуют.
package com.javarush.task.task21.task2104;
import com.sun.org.apache.bcel.internal.generic.ARETURN;
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;
}
@Override
public boolean equals(Object o)
{if (this==o)return true;
if (o==null)return false;
if (o.getClass()!=this.getClass()) return false;
Solution other=(Solution)o;
return other.first!=null&&this.first.equals(other.first) &&other.last!=null&& this.last.equals(other.last);
}
@Override
public int hashCode() {
int result=1;
final int pr=31;
result=pr*result+((first==null)?0:first.hashCode());
result=pr*result+((last==null)?0: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")));
}
}