/*static修饰的方法和变量是属于类的,不属于类实例的*/
class test{
public static void main(String args[]){
Father f = new Father();
Father c = new Child();
System.out.println(f.getName());//Father
System.out.println(c.getName());//Father
}
}
class Father{
public static String getName(){
return "Father";
}
}
class Child extends Father{
public static String getName(){
return "Child";
}
}
******************
class test{
public static void main(String args[]){
Father f = new Father();
Father c = new Child();
System.out.println(f.getName());//Father
System.out.println(c.getName());//Father
}
}
class Father{
public String getName(){
return "Father";
}
}
class Child extends Father{
public String getName(){
return "Child";
}
}