It is related to the subMap method. The subMap method returns a view of the portion of this map. That view is also a NavigableMap i.e. it implements NavigableMap. You may read the details here: https://docs.oracle.com/en/java/javase/ ... leMap.html
So sub map of a NavigableMap is a NavigableMap by definition.
Then why does it say "must implement"?
Is this for the people who implement another implementations of NavigableMap? That they should narrow a subMap method to return NavigableMap, not SortedMap?
But if so, it's still only a suggestion, right? Because they still can make it implement SortedMap like it is in interface definition.
Well, that statement has been taken directly from the JavaDoc API description (link given above). I am guessing that by must they really mean "strongly adviced" because the return type of one of the submap methods is SortedMap instead of NavigableMap. The doc says, "Methods subMap(K, K), headMap(K), and tailMap(K) are specified to return SortedMap to allow existing implementations of SortedMap to be compatibly retrofitted to implement NavigableMap, but extensions and implementations of this interface are encouraged to override these methods to return NavigableMap."
>So sub map of a NavigableMap is a NavigableMap by definition.
I am not sure what you mean by this statement. By what "definition"?
You wrote that the result of subMap method is NavigableMap - that's why it was obvious for me that sub map will always be navigable map.
But now I see there are two subMap methods, with different return types. And I will assume this is the recommendation, since I don't have better explanation for this "must".
Still I feel it should rather say something like "subMap methods should narrow return type", not "submaps must implement". How the returned instance can implement anything? It's rather a method/class which can implement anything... Unless by "submaps" they meant method, I don't know...