为什么编译?
B在A中使用,没有任何通用参数,这是用Java编译的.这里发生了什么?
interface B<T>
{
public T Foo(T value);
}
public class A
{
public B What()
{
return null;
}
public void Foo()
{
B x = What();
x.Foo(123);
}
}
Run Code Online (Sandbox Code Playgroud)
你只是raw
在B
这里使用一种类型.就像
List list = new ArrayList(); // defined as: public interface List<E>
Run Code Online (Sandbox Code Playgroud)
完美,有效; 不推荐.