Tell the difficulties that i am difficult.
saloni jhanwar wrote:I am not getting, why headMap() functionality is totally different than headSet().I thought, it should print all elements from k1 to k2 but it is printing only last element of k1 and k2 ? what is this ?
F:\OCJP\Chapter7\TreeMap>java NaviBack
a
f
gurpeet singh wrote:
saloni jhanwar wrote:I am not getting, why headMap() functionality is totally different than headSet().I thought, it should print all elements from k1 to k2 but it is printing only last element of k1 and k2 ? what is this ?
F:\OCJP\Chapter7\TreeMap>java NaviBack
a
f
why you think it should print all elements of k1, k2. let me give you a hint. it is a treemap. which means keys should be unique, which means not all values corresponding to all k1's won't be added to the map. if you check the api for put method it says that put method will replace the previous mapping if it is already there. so the latest value will be added.
Tell the difficulties that i am difficult.
Thanks & Regards, Sumeet
SCJP 1.4, SCWCD 5, LinkedIn Profile
saloni jhanwar wrote:why headMap() functionality is totally different than headSet().
Tell the difficulties that i am difficult.
Thanks & Regards, Sumeet
SCJP 1.4, SCWCD 5, LinkedIn Profile
Seetharaman Venkatasamy wrote:the question is why map replaces existing value? because it is designed in that way
Tell the difficulties that i am difficult.
saloni jhanwar wrote:it is possible that two or many different objects have same hashcode so they both can't reside in ?
Consider Paul's rocket mass heater. |