Question: public static void sortbykey() { ArrayList sortedKeys = new ArrayList (hash_map.keySet()); Collections.sort(sortedKeys); for (Double x : sortedKeys) System.out.println(Key = + x + , Value

public static void sortbykey() { ArrayList sortedKeys = new ArrayList<>(hash_map.keySet()); Collections.sort(sortedKeys); for (Double x : sortedKeys) System.out.println("Key = " + x + ", Value = " + hash_map.get(x)); } This code can sort my hash_map by keys and print values in order but I just want to see max 5 keys and values not all sorted hash_map 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!