大哥,首先,你这代码太乱了,第2,2个成员变量都是INT型,你的获取面积方法返回DOUBLE型,能输出才有鬼,曾四豆...我给你改了一下,结果就出来了.自己看吧.- interface Shape
 
 - {
 
 -           
 
 -                 void getArea();
 
 -          
 
 - }
 
  
- class Rec implements Shape
 
 - {
 
 -          private double len;
 
 -                  private double wid;
 
 -          
 
 -          Rec(double len,double wid)
 
 -          {
 
 -              this.len = len;
 
 -              this.wid = wid;
 
 -          }
 
  
-          public void getArea()
 
 -          {
 
 -             
 
 -                         System.out.println(len * wid);
 
 -          }
 
  
- }
 
  
- class ExceptionTest1
 
 - {
 
 -       public static void main(String[] args)
 
 -       {
 
 -               Rec r = new Rec(5.00,3.00);
 
 -               r.getArea();
 
 -             
 
 -       }
 
 - }
 
  
  复制代码 |