java - Java中接口和类的继承
问题描述
我不明白为什么在下面的代码中“jm(b)”的输出是“m_AA and m_BA”而不是“m_BB”。谢谢你。(仅适用于:我不知道我要写什么,我不知道我要写什么,我不知道我要写什么,我不知道我要写什么,我不知道我要写什么。)
interface I {
public void m(A a);
public static void stampa() {
System.out.println("stampa");
}
class IImpl {
public static void m(B b) {
System.out.println("m_IB");
}
}
}
class A extends I.IImpl implements I {
public void m(A a) {
System.out.println("m_AA");
}
}
class B extends A {
public void m(A a) {
super.m(a);
System.out.println("m_BA");
}
public static void m(B b) {
System.out.println("m_BB");
}
}
public class Exercise {
public static void main(String[] args) {
B b = new B();
I j = new B();
j.m(b);
System.out.println();
}
}
解决方案
推荐阅读
- node.js - 为什么我不能在 Mongoose Schema 键的开头使用 $ 字符
- azure - 将 Azure AD 用户扩展添加到 id 令牌声明时出现问题
- typescript - 打字稿:类返回空对象
- php - 来自 php 表单的问题/错误,用于使用 php-mailer 库通过本地主机 Xampp 发送电子邮件
- apache-kafka-streams - 应用程序实例终止时重置 Kafka Streams 指标
- excel - 定义返回空白的自定义 VBA 函数
- java - 无法使用配置的 PublicKey 验证 RSA 签名。签名长度不正确:得到 255 但预期为 256
- ruby - 使用服务器规范构建 Rakefile 以测试端口 - 获得 0 个示例,0 个失败
- css - textarea 与输入字段的宽度不同
- javascript - 试图在 jsChart 中的数据中输入二维数组