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()-

相关推荐
天若有情6733 小时前
从零搭建校园二手交易系统:Vue2 + SpringBoot 4.x 全栈实战
java·spring boot·后端
学逆向的3 小时前
C 浮点数e(科学计数法)
c语言·开发语言·网络安全
lexiangqicheng3 小时前
1,自定义表单通俗理解-PC设计APP渲染
java·前端·javascript
quantdash_cc3 小时前
如何给自己的量化策略增加独立数据层?从数据获取到策略解耦的 Python 实践
开发语言·python·数据分析·量化交易·股票数据·quantdash
NeoGressAI外贸数字化3 小时前
外贸独立站3类页面合格度,怎么用脚本一次跑完
开发语言·python
南极企鹅3 小时前
生产环境gc文件分析
java·jvm·算法
Wang's Blog3 小时前
Java 项目实战: 交友项目 - 前后端分离的工程实践
java·spring cloud·架构
X北辰北3 小时前
C++ 进阶第二阶段总结|STL容器全家桶、迭代器失效、STL算法、序列化入门(工程必备)
开发语言·c++·算法
溪语流沙3 小时前
面试加分项!Manacher:O(n)求最长回文子串的对称之美
java·python·leetcode·面试·职场和发展