开发者

Why some interface methods are overriden by another interface?

开发者 https://www.devze.com 2023-04-12 10:33 出处:网络
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

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

精彩评论

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

关注公众号