2011年12月29日星期四

第9天第3节: final关键字、抽象类

==Final
   final on class: this class can not be inheritanced
   final on a method: this method can not be overriding
   final on a field: this is a constant. usually the name is capitalized

   public static final: a global constant shared by all objects

==Abstract class
   abstract class: a class contains any abstract method
   abstract method: a dummy method has declaration without implementation
   Example:
   public abstract class A {
         public String name = "hello";
         public abstract void print();
   }
   abstract class must be extended, all abstract method must has implementation


没有评论: