关于return的用法
程序代码:public class Box {
int length,width, height,volume;
int v;
public Box(int length, int width, int height) {
super();
this.length = length;
this.width = width;
this.height = height;
}
public int getLength() {
return length;
}
public void setLength(int length) {
this.length = length;
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public int getvolume() {
return volume;
}
public void setvolume(int volume) {
this.volume = volume;
}
public int calcVolume(){
v=length*width*height;
System.out.println(v);
return v;
}
public void print(){
System.out.println(v);
}
public static void main(String[] args) {
Box box=new Box(10,15,12);
box.print();
box.calcVolume();
}
}运行结果是:0
1800
return 在这里要怎么用
为什么是0?
坐等高手回答~











