This code which defines a complete Set implementation using
This code which defines a complete Set implementation using a binary search tree. Unfortunately, its Iterator does not throw any exceptions when its results may not be correct. Fix this by updating the class so the Iterator is a fail-fast Iterator.
Code:
Solution
public boolean add(E element) { if (root == null) { if (element == null) { throw new NullPointerException(); } root = new Entry<>(element, null); size++ ; return true; } else { Entry