当前位置:网站首页>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
边栏推荐
- Zipkin入门
- Qiao NPMS: get the download volume of NPM packages
- In place reversal of a LinkedList
- [programming development] markdown notes tutorial
- (二)从架构设计角度分析AAC源码-我的LiveData
- E. X的放大与缩小(运算符重载)
- 剑指 Offer 40. 最小的k个数
- Idea annotation settings
- Don't want the project out of control? You need to use project management tools
- Timestamp of PostgreSQL and Oracle
猜你喜欢

使用express+mysql创建一个基于nodejs的后台服务

qiao-lerna:lerna辅助工具

显示器要申请BS 476-7 怎么送样?跟显示屏一样吗

leetcode - 739. Daily temperature

Mazhiqiang: research progress and application of speech recognition technology -- RTC dev Meetup

leetcode - 230. 二叉搜索树中第K小的元素

Sword finger offer 51 Reverse pair in array

Not eligible for getting processed by all beanpostprocessors

c语言打印心形

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
随机推荐
2022 Niuke winter vacation 3
使用express+mysql创建一个基于nodejs的后台服务
js 中 Map 和 Set 的用法及区别
欧洲家具EN 597-1 跟EN 597-2两个阻燃标准一样吗?
Award winning survey | how Apache pulsar lived in 2022, you the final say
标准化编写知识
go for it Easily manage all types of items with "flying items"
B+超强树,带你知晓MySQL的底层是怎样的结构
leetcode - 230. The k-th smallest element in a binary search tree
c语言打印心形
Sword finger offer 10- ii Frog jumping on steps
GCC AVR(Atmel Studio+ AVR Studio)如何将结构体数组定义在程序存储器(flash)空间并进行读操作
Installation (detailed illustration) and use of SVN
CMVSS TSD No. 302与49 CFR 571.302测试方法是否一样
补2:圆环回原点问题
Pg/oracle database ASCII code to string custom function
Swagger study notes
Sword finger offer 62 The last remaining number in the circle
Type of SQL command (incomplete)
C语言打印菱形