tostring我只输出属性值没类名和属性名
package 父子类; public class Son extends Father { public Son(){ age=20; System.out.println("子类构造方法"); } public void method(){ System.out.println(age); } @Override public String toString() { return "Son [age=" + age + "]"; } }
package 父子类; public class Son extends Father { public Son(){ age=20; System.out.println("子类构造方法"); } public void method(){ System.out.println(age); } @Override public String toString() { return "Son [age=" + age + "]"; } }
2019-02-16
举报