The Sample code given below will test your knowledge of HashMap of Collection framework in Java.
The Sample code given below will test your knowledge of HashMap of Collection framework in Java.Given below the sample code :
4. HashMap hm = new HashMap();
5. hm.put("key45", "some value");
6. hm.put("key12", "some other value");
7. hm.put("key39", "yet another value");
8. Set a = hm.keySet();
9. // insert code here
What code should be at line 9 to sort the keys in HashMap "hm"?
1. a = new SortedSet(a) ;
2. Collections.sort(a);
3. a = new TreeSet(a);
4. a = Collections.sort(a);
(3)