Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Follwing code in java giving the outout as
2=two
1=one
6=three

Is not there any specific order to print the key value pair?


HashMap map=new HashMap();
map.put("1", "one");
map.put("2", "two");
map.put("6", "three");
VB
Set keys=map.entrySet();

        for(Object k:keys)
        {
            System.out.println(k);
        }
Posted

1 solution

Use one of the Collections[^] that returns its members in sorted order.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900