为什么在大多数开源Java项目中未将局部变量声明为final? [英] Why are local variables not declared final in most open source java projects?

查看:216
本文介绍了为什么在大多数开源Java项目中未将局部变量声明为final?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我查看OpenJDK,Hibernate或Apache中的Java源代码,我还没有看到任何声明为final的局部变量.

If I look at the java source source code in the OpenJDK or Hibernate or Apache I have yet to see any local variables declared final.

这表明某些最广泛使用的Java软件库的开发人员:

This suggests that the developers of some of the most widely used java software libraries:

  • 不相信final关键字可以提高可读性.

  • do not believe the final keyword improves readablity.

不相信它可以显着提高性能.

do not believe it significantly improves performance.

为什么大多数关于stackoverflow的竞争者都认为应该使用它(基于投票率最高的答复)?

Why do the majority of contrbuters on stackoverflow believe it it should be used (based on the highest voted responses)?

推荐答案

不相信最终关键字 提高可读性.

do not believe the final keyword improves readablity.

某些人(例如我本人)发现final过多会降低可读性.

Some people (such as myself) find excessive finals decreases readability.

不太相信 提高性能.

do not believe it significantly improves performance.

final局部变量不会提高性能.

final local variables does not improve performance.

这篇关于为什么在大多数开源Java项目中未将局部变量声明为final?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆