package com.bjsxt.oop.extendz; import java.util.List; public class Demo { public static void main(String[] args){ Person p = new Person(); p.show(); Student s = new Student(); s.show(); s.show2(); Student s2 = new Student(2); s2.show(); s2.show2(); } } class Person{ public int value; public Person() {} public Person(int value) { this.value = value; } public void show() { value = 12; System.out.println("father---show()"+value); } public void show2() { //value = 12; System.out.println("father---show2()"+value); } } class Student extends Person{ public int value; public Student() {} public Student(int value) { super(value); } public void show() { value=13; System.out.println("son----show()"+value); } public void show2() { super.value = 12; super.show2();//调用父类show2方法 System.out.println(super.value); } }