I have a big confusion in the usage of the "final" keyword between classes and methods. I.e., why do final methods only support inheritance, but not final classes?
final class A{
void print(){System.out.println("Hello, World!");}
}
class Final extends A{
public static void main(String[] args){
System.out.println("hello world");
}
}
ERROR:
cannot inherit from Final A class Final extennds A{ FINAL METHOD IS..
class Bike{
final void run(){System.out.println("run");}
}
class Honda extends Bike{
public static void main(String[] args){
Honda h=new Honda();
h.run();
}
}