当前位置:网站首页>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
边栏推荐
- BS 7176 fire resistance test for upholstered furniture
- 九九乘法表
- CodeTop - 排序奇升偶降链表
- Sword finger offer 51 Reverse pair in array
- c语言打印心形
- [node] NPM part
- ActiveMQ simple tutorial, suitable for beginners, learning notes yyds
- 堆是也可以看成一种树结构,规定根节点必须大于或小于左右子节点,但左右子节点的大小顺序没有规定
- 窗帘做EN 1101易燃性测试过程是怎么样的?
- Getting started with Zipkin
猜你喜欢

【Image Processing】空间域图像增强

Don't want the project out of control? You need to use project management tools

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

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

Heap can also be regarded as a tree structure. It is specified that the root node must be greater than or less than the left and right child nodes, but the size order of the left and right child nodes

Idea pulls items from remote warehouse

centos随笔03:centos8.2安装mysql

ActiveMQ简单教程,适合初学者,学习笔记yyds

AS 3744.1标准中提及ISO8191测试,两者测试一样吗?

窗帘做EN 1101易燃性测试过程是怎么样的?
随机推荐
并查集是什么?你还在为其烦恼?其实就是一个连通图的问题,理解起来没有那么困难
[cvpr2022] intensive reading of querydet papers
九九乘法表
SSM file upload and download
Icml2022 interesting articles
MySQL advanced features, you can read more about it and meet the interview
The leader asked me to rewrite the test code. Should I do the same?
Zipkin入门
窗帘做EN 1101易燃性测试过程是怎么样的?
经典图论,深度优先和广度优先,拓扑,Prim和Krukal,该来温习啦
木板ISO 5660-1 热量释放速率摸底测试
(1) AAC opening - lifecycle, livedata, ViewModel and source code analysis skills of core component principles (Reprint)
Using docker compose to build redis5 cluster
EN45545-2 R26垂直燃烧测试介绍
Implementation of CRF for named entity recognition
Multiple limit of the same field of SQL
Redis6 entry-level tutorial. There are integration cases. You can directly see the integration cases. It is easy to get started
leetcode - 739. Daily temperature
Is the result too different from the goal? With the help of target management, you can reach the target accurately!
不想项目失控?你需要用对项目管理工具