关于final关键字的Java基础 [英] java basics about final keyword
问题描述
final关键字可以用于方法吗?
Can final keyword be used for a method?
推荐答案
绝对! final
关键字几乎可以应用于任何事物,在每种情况下都表示您不再需要更改此设置".
Absolutely! The final
keyword can be applied to just about anything, in each case meaning "you don't get to change this anymore."
这是应用于...时的意思.
Here's what it means when applied to...
变量:您根本无法为变量分配新值(当然,将其呈现为常数)
a variable: You simply cannot assign the variable a new value (rendering it a constant, of course)
一种方法:您不能在子类中重新实现(即覆盖)此方法
a method: You cannot re-implement (i.e., override) this method in a subclass
一个类:您无法定义子类
在每种情况下,我们只是在表明:一旦声明了这个东西,这就是您将看到的最后一个值(或实现).
In each case we're simply indicating: once this thing is declared, this is the last value (or implementation) you'll ever see for it.
这篇关于关于final关键字的Java基础的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!