Java - 扩展自身的接口 [英] Java - Interface extending itself
问题描述
我已经使用这个网站大约6个月了,是时候问我的第一个问题,因为我找不到答案,至少不是我能理解的答案!
I've been using this site for about 6 months now, and its time to ask my first question, because I cant find the answer to this, atleast not an answer that I can understand!
在这段代码中,为什么这个接口会自行扩展?
In this bit of code, why is this interface extending itself?
public interface PositionedVertex<V extends PositionedVertex<V>> {
/**
* @return Position for node data.
*/
public Point getPosition();
}
这段代码不一样吗?:
public interface PositionedVertex<V> {
/**
* @return Position for node data.
*/
public Point getPosition();
}
提前致谢!
推荐答案
接口没有扩展自身。 < V extends PositionedVertex< V>>
是与您的界面关联的泛型类型的绑定。它只是意味着实现此接口的任何类的泛型类型参数本身必须是 PositionedVertex
。
The interface isn't extending itself. The <V extends PositionedVertex<V>>
is a bound on the generic type that is associated with your interface. It just means that the generic type parameter for any class that implements this interface must itself be a PositionedVertex
.
这篇关于Java - 扩展自身的接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!