private static final Integer ONE = new Integer(1);
public static void main(String[] args) {
Map m = new HashMap();
for (int i = 0; i < args.length; i++) {
int freq = (Integer)m.get(args[i]);
m.put(args[i], (freq==0?ONE:freq+1));
}
System.out.println(m.size()+"distinct words detected:");
System.out.println(m);
}
转载于:https://www.cnblogs.com/oraclespace/p/3989356.html