How print out the contents of a HashMap in ascending order based on its values?

前端 未结 13 1505
春和景丽
春和景丽 2020-12-24 11:58

I have this HashMap that I need to print out in ascending order according to the values contained in it (not the keys

13条回答
  •  攒了一身酷
    2020-12-24 12:32

    Try:

    try
    {
        int cnt= m.getSmartPhoneCount("HTC",true);      
        System.out.println("total count of HTC="+cnt);
    }  
    catch (NoSuchBrandSmartPhoneAvailableException e)
    {
        // TODO Auto-generated catch 
        e.printStackTrace();
    }
    

提交回复
热议问题