代码改变世界

final关键字

2016-03-21 14:28  我就是wade  阅读(145)  评论(0)    收藏  举报


 

//
// final class People{
//    
//}
////通过final声明的类不能被继承
//
//
//
//class Student extends People{Í
//
//}
//
//
//public class FinalDemo01 {
//
//    public static void main(String[] args) {
//        // TODO Auto-generated method stub
//
//    }
//
//}








//class People {
//    public final void tell(){
//        
//    }//final 方法不能被重写
//}
//class Student extends People{Í
//
//@Override
//public void tell() {
//    // TODO Auto-generated method stub
////    super.tell();
//    
//}
//}
//
//public class FinalDemo01 {
//
//    public static void main(String[] args) {
//        // TODO Auto-generated method stub
//
//    }
//
//}

class People {
    public  void tell(){
        
    }
}
class Student extends People{

}

public class FinalDemo01 {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        final String Name ="hhhhh";
//        name = "343434";//用finali 修饰的属性是常量 不能被修改  名称要大些
        System.out.println(Name);
        

    }

}