package bjsxt.com.map;
class MapDemo01
{
public static void main(String[] args)
{
String[] arr="this is a cat and that is a mice and where is the food? ".split("regex");
Map<String,Integer> map=new HashMap<String,Integer>();
for(String key:arr)
{
if(!map.containskey(key))
{
map.put(key,new Letter(key));
}
Letter value=map.get(key);
value.setCount(value.getCount()+1);
}
for(String key:map.keySet())
{
Letter value=map.get(key);
System.out.println(key+"-->"+value.getCount());
}
}
}
littleOStar
相关分类