나는 이것을 정말로 묻는 법을 모른다. 그러나 같은 ... 이제개체가 할당 된 개체를 가져 오려면 어떻게해야합니까?
Student stud1 = new Student("Shady");
Student stud2 = new Student("Nick");
Student stud3 = new Student("Name");
stud2.addBook(new Book(Book.BOOK_MISERABLES, 3););
우리는 다음과 같은 책 클래스의 변수가 있다고 가정하면 : "책"의 생성자 내부 지금
private Student owner;
그리고 질문 -> 그것을인가를 가능한 "stud2"객체를 가져올 수 있습니까? 생성자에 추가 매개 변수를 추가하지 않고? 그렇다면 어떻게? 나는 그것이 가능하다고 생각한다. 그래서 다음과 같이 될 것이다 :
private Student owner;
public Book(int bookNum, int weeks){
this.owner = this.GET_THE_TARGET_THIS_IS_CALLED_ON;
this.bookNumber = bookNum;
this.time = weeks;
}
아니요, 불가능합니다. 그리고, 나는 왜해야하는지 알지 못합니다. –