Hi I have one problem with the following question answer:
a. Stores key/value pairs. b. Allows null elements, keys, and values. c. Duplicate entries replace old entries. d. Entries are sorted using a comparator or the Comparable interface.
Answer is TreeMap But according to my understanding answer should be g. None of the above as TreeMap doesn't satisfies the second condition "b. Allows null elements, keys, and values." Treemap allows null values but doesn't allow null key . Can anyone give more thought on this and explain to me is anywhere I am wrong in understanding the question or what? Thanks
Karthik Veeramani
Ranch Hand
Joined: Dec 22, 2002
Posts: 132
posted
0
Correct me if im wrong, but cant a TreeMap take 1 null key (and many null values)... I guess the question means only this, by 'accepting null'.
Thanks<br />Karthik<br />SCJP 1.4, CCNA.<br /> <br />"Success is relative. More the success, more the relatives."
Suman Nagelia
Greenhorn
Joined: Mar 17, 2003
Posts: 9
posted
0
As far my understanding of TreeMap it'll not accept any null key.
Rory French
Ranch Hand
Joined: Apr 03, 2003
Posts: 97
posted
0
try the following code. It compiles and runs. So I guess TreeMapdoes accept a null key and null values.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.