目前用的是 jdk8 144 版本,写了如下一个方法
Map<String, Object> map = new HashMap<>(); map.put("a", new ArrayList<String>()); methodA((Collection) map.get("a")).stream() .forEach(p -> System.out.println(p.getClass())); methodA((Collection<String>) map.get("a")).stream() .forEach(p -> System.out.println(p.getClass())); 如下为 methodA
List<String> l = new ArrayList<>(); l.add("a"); l.add("b"); return l; 两端输出都是 String 类型, 然而推断类型的时候,第一个调用的参数 p 为 Object,第二个为 String。。。
