当前位置:网站首页>String类为何final修饰
String类为何final修饰
2022-06-11 08:42:00 【JUST DO YOU LIKE】
展开全部
主要是为了“效率” 和 “安全性” 的缘故。若 String允许被继承, 由于它的高度被使用率, 会降低性能,所以String被final修饰。
带有final修饰符的类是不可派生的。在Java核心API中,有许多应用final的例子,例如java.lang.String。为String类指定final防止了人们覆盖length()方法。另外,如果指定一个类为final,则该类所有的方法都是final。Java编译器会寻找机会内联(inline)所有的final方法(这和具体的编译器实现有关)。此举能够使性能平均提高50%。
————————————————
版权声明:本文为CSDN博主「Zain Mei」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_30020909/article/details/114216745
边栏推荐
- 窗帘做EN 1101易燃性测试过程是怎么样的?
- Mazhiqiang: research progress and application of speech recognition technology -- RTC dev Meetup
- 补2:圆环回原点问题
- Timestamp of PostgreSQL and Oracle
- leetcode - 739. Daily temperature
- Codeworks round 680 div2
- 剑指 Offer 40. 最小的k个数
- qiao-npms:获取npm包下载量
- 【clickhouse专栏】新建库角色用户初始化
- Don't want the project out of control? You need to use project management tools
猜你喜欢
随机推荐
2022 Niuke winter vacation 3
二、渲染 Camera 的数据
Installing MySQL and cluster operation on virtual machine in Linux system
MySQL upgrade
K8S应用(四)—— 搭建redis5 集群(可供外部直接访问)
Usage and difference between map and set in JS
Introduction to database system experiment report answer Experiment 6: advanced query of data table
Installation (detailed illustration) and use of SVN
How to solve the MySQL deadlock problem? Recitation version
GCC AVR(Atmel Studio+ AVR Studio)如何将结构体数组定义在程序存储器(flash)空间并进行读操作
[node] NPM part
redis6 入门级教程,有整合案例,可以直接看整合案例,简单入门,直接上手
Codetop - sort odd ascending even descending linked list
Matlab学习7-图像处理之线性平滑滤波
利用docker-compose搭建redis5集群
九九乘法表
vagrant 安装踩坑
Interfaces and abstract classes
Screaming Frog Log File Analyser 中文版安装教程
ActiveMQ simple tutorial, suitable for beginners, learning notes yyds


![[Clickhouse column] user initialization of new library role](/img/00/a11fb1a8e38ed4e0634839160c8ead.png)






