关于final关键字的Java基础 [英] java basics about final keyword

查看:73
本文介绍了关于final关键字的Java基础的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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屋!

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