collections - Java - HashSet best way to implement iterator that does not support remove() -


I have a class that uses HashSet and I want to classify Implemented Iterable , I do not want the square iterator to support the deletion () method.

The default ister of HashSet is hashasht.cayitator which is a private class within the hashshat class, so I Can not expand and override the removal method.

Ideally I would like to avoid writing a wrapper class for KeyIterator , but I'm at a loss how I can easily and simply in my own Iterator

Cheers,

Pete

"Text">

  java.util.Collections.unmodifiableSet (myHashSet) .iterator ();  

Comments