No coding abaixo, porque o Box<? extends T>
usa do extends e o EqualityComparator<? super T>
usa do super T? de modo a fazer a parte do código println
retornar verdadeiro?
public boolean containsSame
(Box<? extends T> other, EqualityComparator<? super T> comparator){
return comparator.compare(get(),other.get());
}
public interface EqualityComparator<T> {
public boolean compare(T first, T second);
}
Box<Number> nBox = new Box<Number>(42);
Box<Integer> iBox = new Box<Integer>(42);
EqualityComparator<Object> sameObject = new EqualityComparator<Object>() {
public boolean compare(Object o1, Object o2) { return o1 == o2;}
};
System.out.println(nBox.containsSame(iBox, sameObject));