java final关键字

Example5_9.java

class A {
  final double PI=3.1415926;// PI是常量
  public double getArea(final double r) {
     return PI*r*r;
  }
  public final void speak() {
     System.out.println("您好,How's everything here ?");
  } 
}
public class Example5_9 {
   public static void main(String args[]) {
      A a=new A();
      System.out.println("面积:"+a.getArea(100));
      a.speak();     
   }
}

 

posted @ 2016-10-23 18:43  我有一壶酒  阅读(230)  评论(0编辑  收藏  举报