java吧 关注:1,289,471贴子:12,819,288
  • 2回复贴,共1

求助:第一次编译说找不到符号,第二次编译却成功了

取消只看楼主收藏回复

interface CaculateArea{
float area(float r);
float area(float l,float w);
float area(float up,float down,float height);
}
class Area1 implements CaculateArea{
public float area(float r){
return (float)Math.PI*r*r; //圆
}
public float area(float l,float w){ //矩形
return l*w;
}
public float area(float up,float down,float height){//梯形
return (up+down)*height/2;
}
}
class Area2 extends Areal{
public float area(float r){ //正方形
return r*r;
}
public float area(float l,float w){ //三角形
return l*w/2;
}
}
class User{
float area(CaculateArea p,float r){
return p.area(r);
}
public static void main(String[]args){
float result,result1;
Area1 p=new Area1();
Area2 p1=new Area2();
User use=new User();
result=use.area(p,10);
result1=use.area(p1,10);
System.out.println("result="+result+"\n"+"result1="+result1);
}
}


1楼2011-11-10 23:56回复
    第一次总说找不到符号Area1,Area2,后来,我把,
    改成
    CaculateArea p=new Area1();
    CaculateArea p1=new Area2();
    再编译,说找不到符号Area1,Area2没事了,又编译就都通过了,后来,改回最初的代码,编译也没问题了,好奇怪啊!
    


    2楼2011-11-11 00:04
    回复
      2025-11-29 10:43:36
      广告
      不感兴趣
      开通SVIP免广告


      3楼2011-11-11 13:08
      回复