当前位置:网站首页>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易燃性测试过程是怎么样的?
- 用飞项进行目标管理,不做职场上的“无头苍蝇”
- Idea annotation settings
- C语言打印菱形
- Installing MySQL and cluster operation on virtual machine in Linux system
- (2) Analysis of AAC source code from the perspective of architecture design - my livedata
- 驱动壳美国测试UL 2043 符合要求有哪些?
- Matlab学习7-图像处理之线性平滑滤波
- GCC AVR (ATMEL studio+ AVR studio) how to define the structure array in the program memory (flash) space and read it
- 光伏板怎么申请ASTM E108阻燃测试?
猜你喜欢

剑指 Offer 40. 最小的k个数

怎么做好项目管理?学会这4个步骤就够了

Idea pulls items from remote warehouse

处理RAW格式的图像,需要什么软件?

Matlab学习7-图像处理之线性平滑滤波

ActiveMQ simple tutorial, suitable for beginners, learning notes yyds

堆是也可以看成一种树结构,规定根节点必须大于或小于左右子节点,但左右子节点的大小顺序没有规定

剑指 Offer 10- II. 青蛙跳台阶问题

领导让我重写测试代码,我也要照办嘛?

Installing MySQL and cluster operation on virtual machine in Linux system
随机推荐
驱动壳美国测试UL 2043 符合要求有哪些?
(二)从架构设计角度分析AAC源码-我的LiveData
In place reversal of a LinkedList
Redis cluster in Linux system
剑指 Offer 62. 圆圈中最后剩下的数字
Type of SQL command (incomplete)
CodeTop - 排序奇升偶降链表
Multiple limit of the same field of SQL
Using docker compose to build redis5 cluster
Empty difference between postgrepsql and Oracle
命名实体识别之CRF的实现方式
Screaming Frog Log File Analyser 中文版安装教程
一些学习记录i=
Polymorphic interview questions
盘它!用「飞项」轻松管理各类型项目
Matlab学习7-图像处理之线性平滑滤波
BS 7176 fire resistance test for upholstered furniture
ActiveMQ simple tutorial, suitable for beginners, learning notes yyds
Web design and website planning assignment 11 game selection form
【Image Processing】空间域图像增强