[英]Redundant super interface warning in eclipse
Why could this construct generate an error/warning in Eclipse? 为什么这个构造会在Eclipse中生成错误/警告? I understand for what it will generate a report, but I guess there must be some rationale, what can go wrong, if you spell out those redundant super interfaces. 我理解它将生成一个报告,但我想必须有一些基本原理,如果你拼出那些冗余的超级接口,会出现什么问题。
Example: 例:
interface I1{
void boo();
}
class A implements I1 {
public void boo() {}
}
class B extends A implements I1 {
public void boo() {}
}
The warning is in B, near implements I1 . 警告在B中,靠近工具I1 。
Imaging if class A
implement I1
and class B
extends A
. 如果A
类实现I1
和B
类扩展A
则成像。 By default B
implements I1
even though it does not need to implement any method in I1
. 默认情况下, B
实现I1
即使它不需要在I1
实现任何方法。 If A
were to change to implement I2
, B
would still compile. 如果A
要改为实现I2
, B
仍然会编译。
However, if B
explicitly implements I1
but does not provide the methods, then this change would cause B
to no longer compile. 但是,如果B
显式implements I1
但不提供方法,则此更改将导致B
不再编译。
Of course, I am ignoring the issues of users of B
that might be assuming that B
implements I1
. 当然,我忽略了可能假设B
实现I1
的B
用户的问题。 Let's assume for this case that that is not an issue. 让我们假设这个案例不是问题。
It's only a warning, and I guess it has two reasons: 这只是一个警告,我猜它有两个原因:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.