class Person
{
private void method()
{
System.out.println("method");
}
public void show()
{
method();
System.out.println("hello world");
}
}
class Student extends Person
{
public void function()
{
//method();
show();
}
}
class Teacher
{
}
class ExtendsDemo
{
public static void main(String[] args)
{
//创建对象
Person p = new Person();
p.show();
//p.method();
Student s = new Student();
s.show();
//s.method(); 不能继承非私有化的方法
}
}
|
|