child
public class Child extends Father{
String name = "Child";
void fun(){
System.out.println("child+++");
}
void fun(double b){
}
int fun(char ch){
return 0;
}
}
father
//重写和 重载的区别
// 重写(覆盖) 子类和父类的方法 重名 分别在两个类中
// 重载 同一个类中 ....
String name = "father";
void fun(){
System.out.println("father!!!");
}
void fun(int a){
}
}
maintest
public static void main(String[] args) {
Child child = new Child();
//子类方法 和父类方法 一模一样
// 子类引用.方法 具体实现子类说了算
child.fun();
System.out.println( child.name);
}
}