我在编译一个子类时,出现如下错误,请问如何解决啊
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
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
代码的开头申明了package没有?
//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;
}}
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;
}}