帮你改了下,看来你很多概念都不清楚,需要努力啊!
class Hehe{
int chang;
int kuan;
int gao;
int volume;
Hehe(int chang1,int kuan1,int gao1){
chang=chang1;
kuan=kuan1;
gao=gao1;
}
void tiji(){
volume=chang*kuan*gao;
}
void print(){
System.out.println("体积为:"+volume);
}
public static void main(String []args){
Hehe tiji1=new Hehe(1,2,3);
tiji1.tiji();
tiji1.print();
Hehe tiji2=new Hehe(2,5,3);
tiji2.tiji();
tiji2.print();
Hehe tiji3=new Hehe(3,2,3);
tiji3.tiji();
tiji3.print();
}
}
class Hehe{
int chang;
int kuan;
int gao;
int volume;
Hehe(int chang1,int kuan1,int gao1){
chang=chang1;
kuan=kuan1;
gao=gao1;
}
void tiji(){
volume=chang*kuan*gao;
}
void print(){
System.out.println("体积为:"+volume);
}
public static void main(String []args){
Hehe tiji1=new Hehe(1,2,3);
tiji1.tiji();
tiji1.print();
Hehe tiji2=new Hehe(2,5,3);
tiji2.tiji();
tiji2.print();
Hehe tiji3=new Hehe(3,2,3);
tiji3.tiji();
tiji3.print();
}
}
你再试试