import java.util.*;
class cylinderTest{
public static void main(String args[]){
cylinder c1=new cylinder();
c1.getInfo();
}
}
class cylinder{
double r;
double h;
cylinder(){
this.r=5.0;
this.h=5.0;
}
cylinder(double r,double h){
this.r=r;
this.h=h;
}
double getArea(){
return(Math.PI*r*r*h);
}
double getV(){
return((Math.PI*2*r*h)+(Math.PI*r*r));
}
void getInfo(){
System.out.println("Area="+getArea()+" V="+getV());
}
}
怎么同时输出JAVA类里面的两个属性?
最新推荐文章于 2023-03-04 16:38:22 发布