IDEA 创建第一个对象
import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;
class Box{
double width;
double height;
double depth;
double volume(){
return width*height*depth;
}
void setDim(double w,double h,double d){
width=w;
height=h;
depth=d;
}
}
public class test03 {
public static void main(String[] args){
Box myBox=new Box();
Box hisBox=new Box();
double myVol,hisVol;
myBox.setDim(10,20,15);
hisBox.setDim(3,6,9);
myVol=myBox.volume();
hisVol=hisBox.volume();
System.out.println("myVol is: "+myVol);
System.out.println("hisVol is: "+hisVol);
}
}
![在这里插入图片描述](https://img-blog.csdnimg.cn/20200508102139811.png)