### Question:
DuplicateOnWriteSimpleCollection implements SimpleCollection<E> { public DuplicateOnWriteSimpleCollection<E> remove(E element) { final Object[] tmpElements = new Object[elements.length]; boolean removed = false; int tmpArrayPos = 0; for (Object currentElement : elements) { if (!removed && currentElement.equals(element)) { removed = true; } else { tmpElements[tmpArrayPos] = currentElement; tmpArrayPos++; } } if (removed) { final Object[] shrunkArray = Arrays.copyOf(tmpElements, tmpArrayPos); return new DuplicateOnWriteSimpleCollection<>(shrunkArray); } else { return this; } } private  DuplicateOnWriteSimpleCollection(); private  DuplicateOnWriteSimpleCollection(Object[] collection); @Override int size(); @Override boolean isEmpty(); @Override Iterator<E> iterator(); @Override Iterator<E> structuralIterator(); DuplicateOnWriteSimpleCollection<E> add(E element); DuplicateOnWriteSimpleCollection<E> remove(E element); DuplicateOnWriteSimpleCollection<E> replace(E newElement, E oldElement); static DuplicateOnWriteSimpleCollection<E> create(); static DuplicateOnWriteSimpleCollection<E> create(E[] array);  }### Answer:
@Test public void remove() { final DuplicateOnWriteSimpleCollection<String> collection = DuplicateOnWriteSimpleCollection.create(); final DuplicateOnWriteSimpleCollection<String> modifiedCollection0 = collection.add("a"); final DuplicateOnWriteSimpleCollection<String> modifiedCollection1 = modifiedCollection0.remove("a"); assertEquals(1, modifiedCollection0.size()); assertEquals("a", modifiedCollection0.iterator().next()); assertEquals("a", modifiedCollection0.structuralIterator().next()); assertEquals(0, modifiedCollection1.size()); assertFalse(modifiedCollection1.iterator().hasNext()); assertFalse(modifiedCollection1.structuralIterator().hasNext()); }