toString是继承object类(超类,所有类都继承object类,接口不是类哦)中的方法,要改写这个方法才有意义.
public class Student {
String studentName;
String StudentAge;
public String toString() {
return "Student [studentName=" + studentName + ", StudentAge="
+ StudentAge + "]";//直接通过调toString方法来看,就很方便
}
}
|