当前位置:网站首页>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.
边栏推荐
猜你喜欢

【第四周】MobileNet和HybridSN

ucos任务调度原理

数组与字符串9-翻转字符串里的单词

九、请介绍类加载过程,什么是双亲委派模型?

SolidWorks 操作视频 | 流体分析结果演示

自监督论文阅读笔记Efficient Self-supervised Vision Pretraining with Local Masked Reconstruction

cobalt strike 的基础使用

自监督论文阅读笔记 Self-Supervised Deep Learning for Vehicle Detection in High-Resolution Satellite Imagery

【C语言】输出100~200之间的素数/质数(3种方法)

【C语言】二分查找
随机推荐
g++ parameter description
二分查找2 - x的平方根
MMU 介绍-[TBL/page table work]
Practice of MySql's Sql statement (try how many you can write)
数组与字符串11-反转字符串
ZEMAX | 探索 OpticStudio中的序列模式
二分查找1-实现一个二分查找
ZEMAX | 探究 OpticStudio 偏振分析功能
【C语言】关于数组传参问题/首地址
自监督论文阅读笔记 Self-Supervised Visual Representation Learning with Semantic Grouping
深度学习理论课程第四、五章总结
ZEMAX | 在OpticStudio中建立扩增实境(VR)头戴式显示器
KASLR-内核地址空间布局随机化
Makefile自动推导的简单例程
二叉树常见的问题和解决思路
数组与字符串15-最大连续1的个数
神经网络之感知机
double型数据转字符串后通过MCU串口发送
cb板上常用的电子元器件都有哪些?
cmdline -[command line,__fdt_pointer,initial_boot_params] boot_command_line 获取