当前位置:网站首页>[use of final keyword]
[use of final keyword]
2022-07-26 09:02:00 【The fifth day of the fifth lunar month】
Concept : keyword final Indicates final , Immutable .
- keyword final You can modify variables 、 Method , class
- final The decorated class cannot be inherited
- When you don't want the methods of the parent class to be overwritten or overridden by subclasses, you can use final
- When you don't want the attribute to be modified, you can use final
- When you do not want a local variable to be modified, you can use final
- final The modified variable can only be assigned a value once
Use details :
- final Modified attributes are also called constants
- final The decorated attribute must be assigned at the time of definition , And cannot be modified later , The assignment position can be found in ( Assign value when defining 、 Constructor assignment 、 Code block assignment ), If final Decorated attributes are static , Only define time or static code block assignment can be used , Do not use constructors
- final Class cannot be inherited , But you can instantiate objects
- If the class is not final class , But there are final Method , Although this method cannot be overridden , But it can be inherited
- Generally speaking , If a class is final class , There is no need to decorate it as final The method
- final Methods cannot modify constructor , That's the constructor
- Packaging (Integer,double,float,Boolean,String All are final class ), Unalterable
边栏推荐
猜你喜欢

day06 作业--技能题6

海内外媒体宣发自媒体发稿要严格把握内容关

【LeetCode数据库1050】合作过至少三次的演员和导演(简单题)

187. Repeated DNA sequence

Study notes of automatic control principle -- dynamic model of feedback control system

Babbitt | metauniverse daily must read: does the future of metauniverse belong to large technology companies or to the decentralized Web3 world

at、crontab

数据库操作 题目二

JDBC数据库连接池(Druid技术)

Vision Group Training Day5 - machine learning, image recognition project
随机推荐
Datawhale panda book has been published!
《Datawhale熊猫书》出版了!
Pan micro e-cology8 foreground SQL injection POC
uni-app 简易商城制作
【ARKit、RealityKit】把图片转为3D模型
[search topics] flood coverage of search questions after reading the inevitable meeting
Cve-2021-26295 Apache OFBiz deserialization Remote Code Execution Vulnerability recurrence
PAT 甲级 A1034 Head of a Gang
The largest number of statistical absolute values --- assembly language
Probability model in machine learning
Cve-2021-21975 VMware SSRF vulnerability recurrence
合工大苍穹战队视觉组培训Day6——传统视觉,图像处理
力扣题DFS
NFT与数字藏品到底有何区别?
Form form
Nuxt - 项目打包部署及上线到服务器流程(SSR 服务端渲染)
CIS 2020 - alternative skills against cloud WAF (pyn3rd)
mysql函数
redis原理和使用-基本特性
at、crontab