相关疑难解决方法(0)

键入擦除,覆盖和泛型

有人可以向我解释原因

@Override
public void fooMethod(Class<?> c)
Run Code Online (Sandbox Code Playgroud)

不会覆盖

public void fooMethod(Class c)
Run Code Online (Sandbox Code Playgroud)

并给我以下错误:

 - Name clash: The method fooMethod(Class<?>) 
of type SubClass has the same erasure as fooMethod(Class) of 
type SuperClass but  does not override it

 - The method fooMethod(Class<?>) of type 
SubClass must override a superclass method

编辑: " java -version"Java(TM)2 Runtime Environment,Standard Edition(build 1.5.0_16-b06-284).至于代码片段,它已经在上面,几乎; 以上扩展了以下内容.

java generics overriding type-erasure

36
推荐指数
1
解决办法
2万
查看次数

标签 统计

generics ×1

java ×1

overriding ×1

type-erasure ×1