0
가 출력 그래도 올 것이다 명령 줄에서 개체에 대해 모든 inforamtion에 표시되지 않습니다 나는 실제로 가지고 :벡터
제목 : XX 가격 : XX
왜 프로그램이 ClassA의 toString을 생략 했습니까?
홈페이지 :
case 'c':
if(!theList.isEmpty()){
for (int i = 0; i < theList.size(); i++)
System.out.println(theList.elementAt(i).toString());
} else {
System.out.println("The list is empty!");
}
break;
를 ClassA의 toString() :
@Override
public String toString(){
StringBuilder result = new StringBuilder();
result.append("Length: ").append(this.getLength()).append('\n');
result.append("Width: ").append(this.getWidth()).append('\n');
return result.toString();
}
ClassB가 년대를 ClassA를 확장, toString() :
@Override
public String toString(){
super.toString();
StringBuilder result = new StringBuilder();
result.append("Title: ").append(this.getTitle()).append('\n');
result.append("Price: ").append(this.getPrice()).append('\n');
return result.toString();
}
내가 사용하는 것이 좋습니다 A ['List'] (http://download.oracle.com/javase/1.5.0/docs/api/java/util/List.html) 대신'Vector' –