### Question:
LinkedTreeSet extends AbstractSet<E> { @Override public Iterator<E> iterator() { return new Iterator<E>() { private final Iterator<E> delegate = orderedElements.iterator(); private E currentElement; @Override public boolean hasNext() { return delegate.hasNext(); } @Override public E next() { currentElement = delegate.next(); return currentElement; } @Override public void remove() { delegate.remove(); LinkedTreeSet.this.remove(currentElement); } }; } LinkedTreeSet();  LinkedTreeSet(Collection<? extends E> other); @Override boolean add(E e); @Override boolean remove(Object o); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override boolean contains(Object o); @Override Iterator<E> iterator(); @Override int hashCode(); @Override boolean equals(Object o); @Override int size(); @Override String toString();  }### Answer:
@Test void testIterator() throws Exception { Set<Object> set = new LinkedTreeSet<>(); set.add(null); set.add("abc"); Iterator<Object> iterator = set.iterator(); assertThat(iterator.hasNext()).isTrue(); assertThatExceptionOfType(IllegalStateException.class) .isThrownBy(iterator::remove); assertThat(set).containsExactly(null, "abc"); assertThat(iterator.next()).isNull(); iterator.remove(); assertThat(set).containsExactly("abc"); assertThat(iterator.hasNext()).isTrue(); assertThat(iterator.next()).isEqualTo("abc"); iterator.remove(); assertThat(set).isEmpty(); assertThat(iterator.hasNext()).isFalse(); }