### Question:
FilteredIterator implements Iterator<T> { @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof FilteredIterator<?>)) { return false; } FilteredIterator<?> that = (FilteredIterator<?>) obj; return predicate.equals(that.predicate) && iterator.equals(that.iterator); } FilteredIterator(Iterator<? extends T> iterator, Predicate<? super T> predicate); boolean hasNext(); T next(); void remove(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); @SuppressWarnings("unchecked") static Iterator<T> filter(Iterator<? extends T> iter, Predicate<? super T> pred);  }### Answer:
@Test public void testEquals() { Iterator<Integer> iter = list.iterator(); FilteredIterator<Integer> t = new FilteredIterator<Integer>(iter, isEven); Predicate<Integer> isOdd = new Predicate<Integer>() { public boolean test(Integer obj) { return obj.intValue() % 2 != 0; } }; Predicate<Float> isOddFloat = new Predicate<Float>() { public boolean test(Float obj) { return obj.intValue() % 2 != 0; } }; assertEquals(t, new FilteredIterator<Integer>(iter, isEven)); assertTrue(!t.equals(new FilteredIterator<Integer>(list.iterator(), isOdd))); assertTrue(!t.equals(new FilteredIterator<Float>(Arrays.asList(0.0f, 0.1f).iterator(), isOddFloat))); assertTrue(!t.equals(null)); }