String [] array = new String
{aa,bb,cc,dd}
Map<String,
Integer> map = new HashMap<String,
Integer>();
for (String str : array)
{
Integer num =
map.get(str);
num = null == num ? 1 : num +
1;
map.put(str, num);
}
Set set = map.entrySet();
Iterator it =
set.iterator();
while (it.hasNext())
{
java.util.Map.Entry <String, Integer>
entry = (Entry<String,
Integer>)it.next();
System.out.println("单词 " + entry.getKey() + " 出现次数 " +
entry.getValue());
}