I have a class that uses a HashSet , and I want to implement the Iterable class, but I don't want the class iterator to support the remove() method.
The default HashSet iterator is HashSet.KeyIterator , which is a private class in the HashSet class, so I cannot just extend it and override the remove method.
Ideally, I would like to avoid writing a wrapper class for KeyIterator , but I don't understand how else I could easily and simply implement my own iterator in any other way.
Any ideas?
Greetings
Pete
java iterator collections
Peter
source share