- public class Test3 {
- public static void main(String[] args) {
- Parent c = new Child();
- System.out.println(c.getName());
- }
- }
- class Parent {
- public static String getName() {
- return "Parrent";
- }
- }
- class Child extends Parent {
- public static String getName() {
- return "child";
- }
- }
复制代码 打印的结果是parent,难道加了static以后就不能实现多态了? |