我在编译一个子类时,出现如下错误,请问如何解决啊
E:\java\开发>javac Cylinder1.java
Cylinder1.java:1: cannot resolve symbol
symbol  : class CircleWithAccessors
location: class Cylinder1
 public class Cylinder1 extends CircleWithAc
                                ^
Cylinder1.java:27: cannot resolve symbol
symbol  : method findArea ()
location: class Cylinder1
   return findArea()*length;
          ^
2 errors

解决方案 »

  1.   

    错误很明显了没有找到类:CircleWithAccessors没有找到方法findArea ()
      

  2.   

    类CircleWithAccessors我是把它和这个子类放在一个目录里,并且可以单独编译啊,怎么会找不到
      

  3.   

    楼主的包结构是什么样子的?
    代码的开头申明了package没有?
      

  4.   

    类CircleWithAccessors如下:
    //CircleWithaccessors.java:the circle class with acessor methods
    public class CircleWithAccessors {
     
       private double radius;//私有成员变量//默认构造函数
      public CircleWithAccessors(){
             radius=1.0;
       }//带一个浮点参数的构造函数
      public CircleWithAccessors(double r){
             radius=r;
       } //返回私有成员变量的值   public double getRadius(){
          return radius;
        }
      //修改私有成员变量的值
       
        public void setRadius(double newRadius){
           radius=newRadius;
         }   //返回圆的面积
       
       public double findArea(){
          return radius*radius*3.14159;
         }}
      

  5.   

    子类Cylinder1如下:
    public class Cylinder1 extends CircleWithAccessors{
         private  double length;                                                                                     //默认构造函数  public Cylinder1(){
       super();
       length=1.0;
       }  //带参数的构造函数
      public Cylinder1(double radius,double length){
        super(radius);
        this.length=length;
      }
      
      //返回length  public double getLength(){
        return length;
       }  //返回体积
      public double findVolume(){   return findArea()*length;
       }}
      

  6.   

    我编译的时候也有问题但是用jbuilder编译通过,可以运行!