方法重写普通方法可以重写1234567891011121314151617181920212223class Animal{ public void eat(){ System.out.println("animal eat"); }}class Cat extends Animal{ @Override public void eat() { System.out.println("cat eat"); }}@Testpublic void test2(){ Animal animal = new Cat(); animal.eat(); animal=new Animal(); animal.eat();}//运行结果://cat eat//animal eat 静态方法不能重写1234567891011121314151617181920212223class Person { public static void test() { System.out.println("Person"); }}class Student extends Person { public static void test() { System.out.println("Student"); }}@Testpublic void test1(){ Person p = new Student(); p.test(); p=new Person(); p.test();}//运行结果://Person//Person