class Super{
static String greeting(){
return "Good night";
}
String name(){
return "Richard";
}
}
class Sub extends Super{
static String greeting(){
return "Hello";
}
String name(){
return "Dick";
}
}
class Test{
public static void main(String[] args){
Super s = new Sub();
System.out.println(s.greeting()+","+s.name());
}
}
运行结果:Good night Dick
父类的静态方法+子类的非静态方法 |