treeMap.entrySet() return 不应该是一个 SortedSet 吗?

Shouldn't treeMap.entrySet() return a SortedSet?

为什么不将 treeMap.entrySet() and treeMap.keySet() methods return SortedSet? I might go so far as saying that is a mistake. As per the API, a Set 定义为没有特定的顺序。但是,TreeMap do 返回的集合具有特定的顺序。

我认为如果他们现在编写接口 SortedMapkeySetentrySet 都会 return SortedSet。但是,在允许协变 return 类型之前,SortedMap 接口在 Java 1.2 中引入。他们现在无法更改此设置,因为将有 SortedMap 的实现,其中 keySetentrySet return 是 Set,而不是 一个SortedSet.