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:

相关推荐
Elias不吃糖1 小时前
RabbitMQ vs Kafka 简单总结
java·分布式·kafka·rabbitmq
xxie1237941 小时前
参数Parameter,形参Formal Parameter,实参Actual Argument
开发语言·python
小短腿的代码世界1 小时前
高性能订单路由与智能拆单算法:Qt在量化交易系统中的核心架构——毫秒级延迟下如何隐藏你的交易意图?
开发语言·qt·架构
nice_lcj5201 小时前
排序(4)-归并排序专题——归并排序的分治美学
java·数据结构·算法·排序算法
阿正的梦工坊1 小时前
【Rust】20-Rust 编译器架构与 MIR/LLVM 优化管线
开发语言·架构·rust
在放️1 小时前
Python 爬虫 · XML、xpath 与 lxml 模块基础
开发语言·爬虫·python
我登哥MVP1 小时前
SpringCloud 核心组件解析:服务调用和负载均衡
java·spring boot·后端·spring·spring cloud·java-ee·负载均衡
插件开发1 小时前
英伟达cuda程序通用性关键 geforce 20xx代到最新版 在20xx上编译的c++程序可以通用吗?
java·c++·人工智能
我要打打代码1 小时前
C# 扩展方法
开发语言·c#