我遇到了代码,编译结果让我感到惊讶。
public class Test3{
public static<K,V> Map<K,V> map(){return new HashMap<K,V>();}
}
class A{
static void f(Map<String,Integer> bcMap){}
public static void main(String[] args){
f(Test3.map()) //not valid
Map<String,Integer> m = Test3.map();//valid
}
}
我一直认为,如果我将值传递给方法,则意味着方法参数分配给传递的值。
是错误的批准吗?