如果我有以下内容:
我该怎么修复这个问题?为什么会出现这个警告提示?
谢谢。
public interface Foo {
<T extends Foo> T getBlah();
}
public class Bar implements Foo {
public Bar getBlah() {
return this;
}
}
我在eclipse中关于Bar类中'getBlah'方法实现的部分收到了一个警告:
- Type safety: The return type Bar for getBlah from the type Bar needs unchecked conversion to conform to T from the type
Foo
我该怎么修复这个问题?为什么会出现这个警告提示?
谢谢。
getBlah
返回的类型必须扩展接口Foo
。但是Bar
并没有扩展它,而是实现了它。 - vulkanino