package com_black.final00; public class Demo { public static void main(String[] args) { zi z=new zi(); z.method(); z.show(); } } package com_black.final00; //当写为public final class fu 此类不可被继承 public class fu { public final void method(){//此方法不可被重写 System.out.println("fu method"); } } package com_black.final00; public class zi extends fu{ /* @Override public void method(){ System.out.println("zi method"); } */ public final int age=30; public void show(){ //age=100; 之前用final修饰后会报错 System.out.println(age); } }
标签:zi,新人,void,笔记,final,public,method,fu From: https://www.cnblogs.com/hxh-/p/17698204.html