本帖最后由 java小兵 于 2015-1-26 21:35 编辑
- class Person
- {
- public String name;
- public int age;
- public Person()
- {
- System.out.println("father");
- say();
- }
- public void say()
- {
- System.out.println("person can say.");
- }
- }
- class Student extends Person
- {
- public String school;
-
- public Student()
- {
- System.out.println("son");
-
- }
- public void say()
- {
- System.out.println("student speak:"+name+age+school);
- }
- }
- class ExtendsDe
- {
- public static void main(String[] args)
- {
- Student s = new Student();
- s.name="jack,";
- s.age=20;
- s.school=",midschool.";
- s.say();
- System.out.println("Hello World!");
- }
- }
复制代码 输出结果是:
father
student speak:null0null
son
student speak:jack,20,midschool.
Hello World!
问题是怎么样去掉结果的前两句??
|
|