8.8 final 关键词

发布时间 2023-06-07 17:34:56作者: 盘思动
  • final 定义不能被继承的类;不能被覆写的方法,常量
  • 最重要作用,定义全局常量
public class HelloWorld {
    public static final String INFO = "mldn";// 定义全局常量;
    public static void main(String args[]){

        String strA = "www.mldn.cn";
        String strB = "www." + INFO + ".cn";
        System.out.println(strA == strB);// true
    }
}