重写 与权限的问题
名剑_无名 2014-08-28 03:01:28 public class Person {
private void print(){
System.out.println("父类");
}
public void printTwo(){
System.out.println("父类");
}
public void fun(){
this.print();
}
public void funTwo(){
this.printTwo();
}
}
public class Student extends Person {
public void print(){
System.out.println("学生");
}
public void printTwo(){
System.out.println("学生");
}
}
public class TestStudent {
public static void main(String[] args) {
Student student =new Student();
student.fun();
student.print();
student.funTwo();
student.printTwo();
}
}
结果:
父类
学生
学生
学生
请教下这两种结果为什么会不同