I think that if they now write the SortedMap interface, both keySet and entrySet will return a SortedSet . However, the SortedMap interface was introduced in Java 1.2 before covariant return types are allowed. They cannot change this now, since there will be SortedMap implementations for which keySet and entrySet returns a Set , which is not a SortedSet .
Paul boddington
source share