转自:
下文是笔者总结出的Java代码中:
Final:
最终的; 决定性的; 不可更改的; 决赛;
是多种编程语言的关键字或保留字
final关键字的功能说明,如下所示:
当一个类被final关键字修饰后,则此类不能被继承,即常说的的最终类
当一个方法被final关键字修饰后,则方法不能被子类重写
当一个变量被final关键字修饰后,则此变量为一个常量(只读)
例:
声明类: final class 类名 {//类体} 声明方法: 修饰符(public/private/default/protected) final 返回值类型 方法名(){//方法体}
public final class String
implements java.io.Serializable, Comparable<String>, CharSequence,
Constable, ConstantDesc {
/**
* The value is used for character storage.
*
* @implNote This field is trusted by the VM, and is a subject to
* constant folding if String instance is constant. Overwriting this
* field after construction will cause problems.
*
* Additionally, it is marked with {@link Stable} to trust the contents
* of the array. No other facility in JDK provides this functionality (yet).
* {@link Stable} is safe here, because value is never null.
*/
@Stable
private final byte[] value;
}