Java Programming Chapter 4——Error in compilation: it cannot be overwritten.

Error in compilation: it cannot be overwritten.

If a method with the same parameter list as the method name of the parent class is defined in the subclass, but the return value type is different, the program compilation error message is

TestAnimal.java:20: Error: sleep () in Dog does not override Sleep () in Animal.

public int Sleep () {

∧ Return type int is incompatible with void. 1 error.

Example:

相关推荐
paopaokaka_luck42 分钟前
滑雪场管理系统(AI智能助手流式对话,ECharts 运营数据分析、教练、雪具与场地一体化预约,钱包支付退款、订单核销与服务评价)
java·人工智能·spring boot·网络协议·数据分析·echarts
阿里嘎多学长1 小时前
2026-10-12 GitHub 热点项目精选
开发语言·程序员·github·代码托管
Wang's Blog1 小时前
Java 项目实战: 交友项目 - Dubbo 的内部结构与一次调用的完整链路
java·dubbo
Wang's Blog1 小时前
Java 项目实战: 交友项目 - Dubbo 入门引导
java·dubbo·交友
wangchunyu1142 小时前
Python 数据可视化实战入门教程
开发语言·python·信息可视化
蜗牛互联网2 小时前
Python Agent工具调用的白名单、参数校验与审批门禁
java·服务器·前端·人工智能·后端·python
SL_staff2 小时前
当规则引擎开始‘懂业务’:JVS-Rules金融风控四大原生能力拆解
java·python·全栈
Shaoshing2 小时前
前缀和与差分
java·数据结构·算法·前缀和·差分
dd聊技术3 小时前
Prompt 从代码常量搬进数据库:改一句话,不用再发一次版
java·后端
ly76893 小时前
Spring Data MongoDB 批量写入实践:BulkOperations 批大小与写关注权衡
java·mongodb·spring·批量写入·bulkoperations·写关注·mongotemplate