Map的一种使用
在Thinking in java中的11.10小节开始,介绍了这么一个例子: 如何检查Java的Random类的随机性,即对落入不同范围的数字进行计数。
?假设你为这个方法传递一个namelist: a,a,b,c,c,c,d,e,f,g,h
在我的电脑上的输出为:
this file has the same name, that name is [c], it was found 3 times.
this file has the same name, that name is [a], it was found 2 times.?
Map与数组和其他的Collection一样,可以很容易的扩展到多维,例如你跟踪拥有多个宠物的人,你可以这样设置
Map<Person, List<? extends Pet>?