아래의 결과 나타나도록 ToString 을 재정의 하시오.
public class ToStringEx {
public static void main (String[] args) {
Book book = new Book(100,"개미");
System.out.println(book);
System.out.println(book.toString());
}
}
public class Book {
int bookNumber;
String bookTitle;
Book (int bookNumber, String bookTitle) {
this.bookNumber = bookNumber;
this.bookTitle = bookTitle;
}
@Override
public String toString() {
System.out.println(bookTitle+" "+bookNumber);
}
}