public class Box{
public int length,width,height;
public int volume;
Box(int i, int j, int k){
this.length=i;
this.width=j;
this.height=k;
}
void setvolume(int i){
this.volume=i;
}
int getvolume(){
return volume;
}
}
class BigBox{
Box B1=new Box(20,30,40);
B1.length=30;
}
클래스 Box의 객체의 길이 변수를 30으로 덮어 쓰는 클래스 Box와 다른 클래스 BigBox를 만들었지 만 코드를 덮어 쓰려면 B1.length = 30이라고 쓰면 오류가 있음을 보여줍니다. 이해할 수 없다. 누구든지 나를 도울 수 있습니까?클래스 상자의 개체 변수가 다른 클래스에서 덮어 쓰지 않는 이유는 무엇입니까?
를 ** 무슨 ** 오류? –
클래스 멤버를 선언 할 때와 동일한 수준으로 문장 (예 : 과제)을 넣을 수 없습니다. – Seelenvirtuose
@OliverCharlesworth 다음과 같은 오류 : 토큰 "길이"에 구문 오류가 발생했습니다.이 토큰 다음에 VariableDeclaratorId가 필요합니다. – aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa