java中的常量变量和最终变量之间有什么区别? [英] What is the difference between constant variables and final variables in java?
问题描述
请帮助我理解常量变量与Java中 final
变量之间的区别。我对它有点困惑。
Please help me understand the difference between constant variables and final
variables in Java. I am a bit confused with it.
推荐答案
常量是概念,变量的属性。
Constant is the concept, the property of the variable.
final
是用于声明常量变量的java关键字。
final
is the java keyword to declare a constant variable.
正如其他人所指出的那样,从语义/语言学的角度来看,表达式常量变量是矛盾的,因此,我们可以争辩它的正确性。
As other people pointed out, from a semantic/linguistic point of view the expression constant variable is an oxymoron and, as such, we could argue about its correctness.
引用规范,无论如何,我们可以阅读
Quoting the specification, anyway, we can read
原始类型的变量[...]是最终的并且使用编译时常量表达式(第15.28节)初始化,称为常量变量。
因此,我认为,为了我们的目的,我们可以接受(并认为正确)这个二项式。
I suppose, hence, that we can accept (and consider correct) this binomial for our purpose.
这篇关于java中的常量变量和最终变量之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!