@iar
2015-10-28T02:10:32.000000Z
字数 1675
阅读 115
java
本文记录搜到的Stack overflow上面的Java tips.
"PECS" is from the collection's point of view. If you are only pulling items from a generic collection, it is a producer and you should use extends; if you are only stuffing items in, it is a consumer and you should use super. If you do both with the same collection, you shouldn't use either extends or super
这个解释也不错: What is a difference between and ?, 和Polymorphism的经典例子: 男女都是人: call pee(), 一个stand(), 一个sit().
见图:
for(Iterator<Map.Entry<String, String>> it = map.entrySet().iterator(); it.hasNext(); )
int[] array = somelist.stream().mapToInt(i->i).toArray();