当前位置:网站首页>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.
边栏推荐
猜你喜欢
VS2022 encapsulates static libraries and calls static libraries under window
【C语言】斐波那契数列
C语言中打印字符数组出现乱码的问题(烫烫烫)
自监督论文阅读笔记 DetCo: Unsupervised Contrastive Learning for Object Detection
VS2022 encapsulation under Windows dynamic library and dynamic library calls
增强光学系统设计 | Zemax 全新 22.2 版本产品现已发布!
二分查找4 - 搜索旋转排序数组
二分查找2 - x的平方根
How the world's leading medical technology company maximizes design productivity | SOLIDWORKS Product Exploration
Practice of MySql's Sql statement (try how many you can write)
随机推荐
STM32启动文件的选择
自监督论文阅读笔记 Self-Supervised Deep Learning for Vehicle Detection in High-Resolution Satellite Imagery
double型数据转字符串后通过MCU串口发送
数组与字符串15-最大连续1的个数
Practice of MySql's Sql statement (try how many you can write)
2021-04-23
自监督论文阅读笔记 Ship Detection in Sentinel 2 Multi-Spectral Images with Self-Supervised Learning
什么是参数化设计,通过实操了解一下? | SOLIDWORKS 操作视频
ZEMAX | 在OpticStudio中建立扩增实境(VR)头戴式显示器
二叉树常见的问题和解决思路
Makefile自动推导的简单例程
C语言中打印字符数组出现乱码的问题(烫烫烫)
自监督论文阅读笔记 S3Net:Self-supervised Self-ensembling Network for Semi-supervised RGB-D Salient Object Det
JSP的基本使用
借助ginput函数在figure窗口实时读取、展示多条曲线的坐标值
ZEMAX | 如何创建复杂的非序列物体
Difference between @JsonProperty and JSONField?
二分查找2 - x的平方根
交叉熵(第六周)
ZEMAX | How to rotate any element around any point in space