1、final方法是可以继承的,但是在子类中不能进行重写:
public class Test {
public static void main (String[] args) {
Horse horse = new Horse();
horse.shuChu();
}
}
class Animal {
final void eat(){
System.out.println("joaj");
}
}
class Horse extends Animal{
void shuChu(){
eat();
}
}
2、final方法被继承后,可以被重载:
public class Test {
public static void main (String[] args) {
Horse horse = new Horse();
horse.eat();
horse.eat(3,2);
}
}
class Animal {
final void eat(){
System.out.println("我是final方法");
}
}
class Horse extends Animal{
void eat(int a, int b){
System.out.println("可以被重载");
}
}