I was just wondering why java.util.Scanner implements java.util.Iterator?
Scanner
implements the remove method and throws an UnsupportedOperationExcept
For an official answer, see the Collections Framework Overview. Scroll down to the bottom for Design Goals.
To keep the number of core interfaces small, the interfaces do not attempt to capture such subtle distinctions as mutability, modifiability, and resizability. Instead, certain calls in the core interfaces are optional, enabling implementations to throw an
UnsupportedOperationException
to indicate that they do not support a specified optional operation. Collection implementers must clearly document which optional operations are supported by an implementation.
As previous answers have pointed out, the Collections framework could uphold Liskov Substition by decomposing its interfaces into numerous, smaller interfaces. That approach was considered and rejected, in order to minimize the number of core interfaces in the framework.