当前位置:网站首页>Overriding Overloading final
Overriding Overloading final
2022-06-21 19:59:00 【卷心菜是真的菜】
final
Java的final和C语言的const不是非常一致
Java中final用来修饰的任何对象都是声明它的引用不可变,它的值可能可以变,可以认为Java中的final修饰变量就相当于指针常量(一个指针,它的值不可变,即指向的地址不可变)
final修饰类不能被继承
final修饰方法不能重写,但能重载
方法签名
如public int test(int, long, java.lang.String[])
可以看出方法签名关注方法的方法名、返回值类型、形参类型、形参类型的顺序,但不关心方法的形参名(和C一致)
Overriding重写
方法签名一致
相当于覆盖原来的方法
如public int test(int a, long b, String c)和public int test(int d, long e, String f)
Overloading重载
方法签名不一致
一个新的方法
如public int test(int a, long b, String c)和public int test(int a)
注意事项
一般在继承中要重写一个方法时最好加上@Override,否则可能会不小心写成重载
边栏推荐
- What is EGFP, green fluorescent protein
- 潮流媒體Hypebeast擬曲線上市:作價5.3億美元 擬第三季完成
- Jinghe integration has passed the registration: it plans to raise 9.5 billion yuan. Hefei Construction Investment and Midea are shareholders
- 在AD中安装元件和封装库
- 拿什么来拯救你?我的注意力
- When Jerry made Bluetooth transmission, when he modified stereo to mono differential output, there was a jam sound at the receiving end [chapter]
- Openjudge noi 1.13 45: decimal to octal
- Do280openshift command and troubleshooting -- accessing resources and resource types
- How to write a proposal for an English paper?
- prototype扩展:实现对象继承
猜你喜欢

Hypebeast, un média à la mode, est sur le point d'être lancé: 530 millions de dollars pour le troisième trimestre

智力题整理总结

杰理之做蓝牙发射的时候,回链没有声音解决方法【篇】

你真的了解二叉树吗?(上篇)

中微半导体通过注册:年营收11亿 实控人为新西兰国籍

InteliJ-IDEA-高效技巧(二)

Data types in JS (basic)

30 groups of outdoor travel vlog record LUTS color matching preset moody travel LUTS

拖延患者自救指南|“我有不拖延的100种借口,却不愿意跨出一步”

怎样有效率地进行外文文献检索?
随机推荐
InteliJ-IDEA-高效技巧(一)
Product innovation - an innovative social app that returns to real life
2022年焊工(高级)考试题模拟考试题库模拟考试平台操作
怎样有效率地进行外文文献检索?
如何解决idea文件被锁Make File Read-Only?
基于接口划分VLAN:静态VLAN【未完善】
大型语言模型教会智能体进化,OpenAI这项研究揭示了二者的互补关系
Unity dynamically reads and plays external music
Caricature scientifique | Vous pouvez apprendre l'EEG en regardant les images. Voulez - vous essayer?
solidity实现智能合约教程(4)-ERC1155合约
Can I open an account for online stock trading? Is it safe
On the charm of code language
Database management: Navicat premium 15
杰理之SD 卡复用 iic 注意问题【篇】
杰理之获取当前音频文件(长)文件名和当前(长)文件夹名【篇】
数据库管理:Navicat Premium 15
可以在网上炒股开户吗?是安全的吗
Tx9116 Synchronous Boost IC
撰写学术论文引用文献时,标准的格式是怎样的?
2022 National latest fire facility operator (intermediate fire facility operator) simulation question bank and answers