java - 在 CanFly 接口中,必须使用一个 CanFly 类型的参数声明 speed 方法
问题描述
在 CanFly 接口中,必须使用一个 CanFly 类型的参数和一个 Double 类型的返回值来声明 speed 方法。参数不知道写什么
public class Solution {
public static void main(String[] args) throws Exception {
}
interface CanMove{
Double speed();
}
interface CanFly extends CanMove{
@Override
public Double speed();
}
}
解决方案
你完全按照任务告诉你的去做。您添加一个带有类型的参数CanFly
并返回一个Double
对象。
public class Solution {
public static void main(String[] args) throws Exception {
}
interface CanMove{
Double speed();
}
interface CanFly extends CanMove{
public Double speed(CanFly target);
}
}
请记住,您必须删除注释,因为您从接口@Override
为现有speed()
方法提供了新的重载。CanMove
推荐阅读
- python - 如何将 null 作为来自 python 的聚合字段的值传递?
- python - 根据 cbar,seaborn 热图没有给出正确的颜色
- c# - 在 AD 中检索用户的 altRecipient 属性的电子邮件地址
- apache-kafka-connect - 如何将新表添加到 Debezium MySQL 连接器?
- python - 如何在 python turtle 中制作余弦波图?
- groovy - JMeter jp@gc-WebDriver Sampler — 从 CSV 文件运行网页
- deep-learning - 多类分类:维度超出范围(预期在 [-1, 0] 范围内,但得到 1)
- mongodb - Monogo DB 更新错误:传入的参数必须是 12 个字节的单个字符串或 24 个十六进制字符的字符串
- javascript - 为什么我的 Vue 导航栏更改了路由但没有更新路由器视图?
- security - 由于完整性错误,Blazor WebAssembly 应用程序无法加载