首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Map的一种施用

2012-09-02 
Map的一种使用在Thinking in java中的11.10小节开始,介绍了这么一个例子: 如何检查Java的Random类的随机性

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>
?

热点排行