当前位置:网站首页>[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
边栏推荐
- P3743 Kotori's equipment
- Rocky基础练习题-shell脚本2
- Regular expression: judge whether it conforms to USD format
- ONTAP 9文件系统的限制
- 基于序的评价指标 (特别针对推荐系统和多标签学习)
- Self review ideas of probability theory
- 公告 | FISCO BCOS v3.0-rc4发布,新增Max版,可支撑海量交易上链
- [leetcode database 1050] actors and directors who have cooperated at least three times (simple question)
- day06 作业---技能题7
- Espressif 玩转 编译环境
猜你喜欢
C Entry series (31) -- operator overloading
Study notes of automatic control principle -- dynamic model of feedback control system
ES6 modular import and export) (realize page nesting)
Clean the label folder
Pop up window in Win 11 opens with a new tab ---firefox
布隆过滤器
第6天总结&数据库作业
【LeetCode数据库1050】合作过至少三次的演员和导演(简单题)
The idea shortcut key ALT realizes the whole column operation
Innovus卡住,提示X Error:
随机推荐
2022年上海市安全员C证考试试题及模拟考试
unity简易消息机制
day06 作业--技能题6
高数 | 武爷『经典系列』每日一题思路及易错点总结
力扣题DFS
Day06 operation -- addition, deletion, modification and query
Kotlin properties and fields
Ueditot_ JSP SSRF vulnerability recurrence
基于序的评价指标 (特别针对推荐系统和多标签学习)
ONTAP 9文件系统的限制
数据库操作技能7
论文笔记: 知识图谱 KGAT (未完暂存)
PAT 甲级 A1034 Head of a Gang
公告 | FISCO BCOS v3.0-rc4发布,新增Max版,可支撑海量交易上链
Set of pl/sql -2
unity TopDown角色移动控制
Mutual transformation of array structure and tree structure
力扣刷题,三数之和
[recommended collection] MySQL 30000 word essence summary index (II) [easy to understand]
Horizontal comparison of the data of the top ten blue chip NFTs in the past half year