Allora, io ho scritto questo codice:
	codice:
	public static Map m=new HashMap(500);
......
public static Iterator count(Iterator itr) {
     Map tree=new TreeMap();
     while (itr.hasNext()) {
         Object k = itr.next();
         if (!tree.containsValue(m.get(k))) tree.put(new Integer(1),m.get(k));
         else {
               Integer val = (Integer) tree.get(k);
	       tree.put(new Integer(val.intValue() + 1),m.get(k));
	      }
     }
     Set s=tree.entrySet();
     Iterator i = s.iterator();
     return i;
}
 
Il porblema è che mi dà una ClassCastException sull'istruzione in neretto. 
 
Non so proprio cosa fare, è da un po' che ci sto ragionando ma non vengo mai a capo di questo problema. 
 
Qualcuno mi dà una mano?