【发布时间】:2009-10-16 17:18:22
【问题描述】:
我读过Beautiful code with Google Collections, Guava and static imports关于Java集合的文章,下面的sn-p引起了我的注意:
Map<String, Map<Long, List<String>>> map = Maps.newHashMap();
问题是,我不明白newHashMap 方法怎么可能返回Map<String,Map<Long, List<String>>>。他们是如何编写这段代码的?什么时候成为可能?我的印象是,您需要在构造函数调用中显式声明泛型参数。
【问题讨论】:
标签: java generics collections