package J20250716.demo04_final; /** * @author WanJl * @version 1.0 * @title Demo01 * @description final 最终的 最后的 * @create 2025/7/16 */ public class Demo01{ //一般final经常会和static一起使用 //这时候这个变量就是静态常量,一般静态常量都会使用全大写进行命名 //使用static修饰的变量是静态成员变量,可以使用类名直接调用 public static final String STRING="春天"; } //父类 class Fu{ //使用final修饰的方法,不能被重写 public final void method(){ } } //子类 //被final修饰的类不能被继承 final class Zi extends Fu{ //不能重写使用final修饰的方法。 // public final void method(){ // // } }