Sample code to retrieve objects from HashMap in sorted
ascending order?

Answer Posted / murli

Map hm = new HashMap();
//add values to hashmap
Map tm = new TreeMap(hm);
//Iterate keySet in tm

Is This Answer Correct ?    9 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do you mean by chromounits in java8?

711


What are inbuilt functions?

740


What are advantages and disadvantages of OOPs?

859


Explain the difference between serializable and externalizable in java?

743


Can a static class implement an interface?

799


When to use runnable interface vs thread class in java?

743


What is the purpose of a volatile variable?

750


Which way a developer should use for creating thread, i.e. Sub classing thread or implementing runnable.

702


Given a singly linked list, find the middle of the list in a single traversal without using temporary variable.

826


what is the purpose of the wait(), notify(), and notifyall() methods? : Java thread

773


What advantage do java's layout managers provide over traditional windowing systems?

735


What is n in java?

723


Define jre i.e. Java runtime environment?

775


What is mean by exception?

746


What is stringjoiner ?

738