Code example for Map.Entry

Methods: getValue

0
    public ArrayList<Entry<V, Integer>> sortByValue() {
        ArrayList<Entry<V, Integer>> list = new ArrayList<Map.Entry<V, Integer>>(
                counter.entrySet());
        Collections.sort(list, new Comparator<Entry<V, Integer>>() {
            public int compare(Entry<V, Integer> o1, Entry<V, Integer> o2) {
                return o2.getValue().compareTo(o1.getValue());
            } 
        }); 
        return list;
    } 
 
    public void dump() { 
        ArrayList<Entry<V, Integer>> list = sortByValue();
        for (Entry<V, Integer> entry : list) {
            System.out.println(entry);
        } 
    } 
 
}