Java NavigableMap why headMap returns different for the same methods

Regarding Java TreeMap method (or NavigableMap interface):

public SortedMap<K,V> headMap(K toKey)
public NavigableMap<K,V> headMap(K toKey, boolean inclusive)

      

Why do they return different types? I know SortedMap is super for NavigableMap, I just want to know why a different return is required for the included flag.

Looking at the code, it makes no sense either that the version without the included flag just calls another.

Thank.

+3


source to share


1 answer


+4


source







All Articles