java - 如何传递祖父母对象来调用父方法
问题描述
Class A {
}
Class B extends A {
public void aMethod(A a){
}
}
class C extends B {
aMethod() /* What argument should i pass in here? I
cannot change class A and Class B */
}
解决方案
由于 C 和 B 都扩展了 A 类,在这种情况下,您可以传递给aMethod
A、B 或 C 类的实例
推荐阅读
- html - 在 Cpanel 中安装新字体
- assembly - MIPS 32 显示错误值并重复打印语句
- node.js - 如何在连接范围之外引用 socket.id 或以可以在连接范围之外引用的方式存储它?
- electron - 在具有上下文隔离的渲染器中使用电子保存对话框
- c# - 总偶数数组
- java - 在java中创建类对象而不使用类名方法的替代方法
- javascript - 如何获取数组中唯一值的*索引*
- ethereum - 从零地址发送交易
- javascript - Angular Uncaught (in promise): ChunkLoadError: Loading chunk XXXfailed
- mysql - mariaDB 上的 json crud