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类里面的两个属性?
Java相关内容
最新推荐文章于 2022-11-04 22:14:32 发布
由于未提供博客具体内容,无法给出包含关键信息的摘要。
134

被折叠的 条评论
为什么被折叠?



