Java Programming Chapter 4——The difference between overloading and overwriting.

The difference between overloading and overwriting.

If a method program with the same method name and return value type as the parent class but different parameter list is queued in the subclass, it will be compiled. At this time, there are two eat methods in the subclass, public void eat(int a){// The two methods that inherit from the parent class are no longer method overrides, but method overloads, so at runtime, which method to call is decided according to the actual parameters.

The result of running the program is

-eat()-

-sleep()-

相关推荐
她的男孩8 小时前
Spring Boot 接 Flowable 工作流:用 3 个注解搭一个请假审批流程
java·后端·架构
荣码10 小时前
LLM结构化输出:让AI返回JSON而不是废话,我踩了4个坑
java·python
plainGeekDev11 小时前
Gson → kotlinx.serialization
android·java·kotlin
小bo波20 小时前
Java Swing 图形用户界面实验 —— 从算术练习到游戏开发的完整实践
java·课程设计·gui·游戏开发·扫雷·swing
咖啡八杯21 小时前
GoF设计模式——备忘录模式
java·后端·spring·设计模式
SamDeepThinking1 天前
裁掉那个差程序员后,给你看团队里高手的代码:这个习惯,希望你有
java·后端·程序员
朕瞧着你甚好1 天前
技术雷达 & Java 集成评估报告 — Apache Tika 3.3.1
java·ai编程
MacroZheng1 天前
短短几天,暴涨2.8万Star!又一款编程神器开源!
java·人工智能·后端