开发者

Why some interface methods are overriden by another interface?

Is it just for documentation purposes (e.g. Deque interface override all methods of the Queue interface, giving them another开发者_JAVA技巧 description), or there are other reasons ?


You can use it to enforce more specific method signatures and return types. Consider:

public interface Foo {
  Object result();
}

public interface Bar extends Foo {
  @Override
  String result(); // Bar redefines result() to return a String
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜