Saikiran,
The method headMap used in the sample code returns a NavigableMap that is linked with your TreeMap (tree) instance.
From JSE 6 Doc API - NavigableMap interface,
the method: NavigableMap<K,V> headMap(K toKey, boolean inclusive)
Returns a view of the portion of this map whose keys are less than (or equal to, if inclusive is true) toKey.
The returned map is backed by this map, so changes in the returned map are reflected in this map, and vice-versa.
Since the returned collection is linked to its source, it must consider the boundaries of this new collection. In this case the boundary is the element that you've used to create your headMap collection ("ee" element).
You can only add elements that are less than "ee" as "dd" or "bb". But never "ff" neither "ee" because you get "ee" was used as exclusively when you set the second argument of headMap to false.
This is your code placed on code tags.
hope this help you