package com.company;
/**
* Created by liuyazhou on 2016/9/21.
*/
public class Test {
public Integer fun(Integer a ,Integer b){ ////如果此方法是private 的,则Main.java中 System.out.println( testSon.fun(1,2));报错
return a+b;
}
}
package com.company;
/**
* Created by liuyazhou on 2016/9/21.
*/
public class TestSon extends Test {
}
package com.company;
public class Main {
public static void main(String[] args) {
// write your code here
System.out.println("123");
TestSon testSon = new TestSon();
System.out.println( testSon.fun(1,2));////子类可以调用父类中的public方法
}
}
输出结果: