public class Circle {
double r;
Circle(double r){
this.r=r;
}
public double getR() {
return r;
}
public void setR(double r) {
this.r = r;
}
double getArea() {
return Math.PI * r * r;
}
double getCircumference() {
return Math.PI * 2 * r;
}
}
---------------------------------------------------
public class Test2 {
public static void main(String[] args) {
Circle circleA=new Circle(10.0);
Circle circleB=new Circle(5.0);
double circlering=circleA.getArea()-circleB.getArea();
System.out.println("圆环面积为:"+circlering);
System.out.println("大圆周长为:"+circleA.getCircumference());
System.out.println("小圆周长为:"+circleB.getCircumference());
}
}