当前位置:网站首页>3. What is the difference between final, finally, and finalize?
3. What is the difference between final, finally, and finalize?
2022-08-03 06:22:00 【Shiyu】
One, final immutable
Usually used to modify a class or a method or a variable
1. When modifying a class, it means that this class cannot be inherited.(Avoid overriding methods, change some functions)
2. When modifying a method, it means that this method cannot be overridden.(same as above)
3. When modifying a variable, it means that the reference to this variable cannot be changed.(Ensure that the value of the variable is correct and avoid being modified randomly)
Second, finally the last
It is usually used with try-catch block to ensure that the last one is processed after some business is processed, such as closing the database connection and waiting.Normally it will be implemented.
Note: It may not be executed. For example, an infinite loop while(true) is used in try or the program System.exit(1), System.exit(0) is exited in advance.
System.exit(0): exit normally
System.exit(1): Abnormal exit
Three, finalize completed
A method of java.lang.obejct, which is used to reclaim some specific resources before the object is reclaimed by the garbage processor.
边栏推荐
猜你喜欢
随机推荐
pandoc -crossref插件实现markdwon文档转word后公式编号自定义
二分查找3 - 猜数字大小
自监督论文阅读笔记SELF-SUPERVISED SPECTRAL MATCHING NETWORK FOR HYPERSPECTRAL TARGET DETECTION
VSCODE 常见问题
ue4学习日记4(植被,光照,光束遮挡,天空球)
cobalt strike 的基础使用
神经网络之感知机
MySql【后面附有练习题】
ucosII OSMemCreate()函数的解析
增强光学系统设计 | Zemax 全新 22.2 版本产品现已发布!
ZEMAX | 如何围绕空间中的任何点旋转任何元素
设备树解析源码分析<devicetree>-1.基础结构
自监督论文阅读笔记 Self-supervised Label Augmentation via Input Transformations
JS--正则表达式
Delightful Nuxt3 Tutorial (2): Build a Blog Quickly and Easily
Makefile自动推导的简单例程
How the world's leading medical technology company maximizes design productivity | SOLIDWORKS Product Exploration
关于C语言中getchar()函数的用法
自监督论文阅读笔记Reading and Writing: Discriminative and Generative Modelingfor Self-Supervised Text Recogn
2021-04-23