Posts

Showing posts with the label final keyword

Usage of final keyword in java

Final Keyword In Java 1) Java final variable If you make any variable as final, you cannot change the value of final variable(It will be constant). final int  ACK //(generally it is the convention to give capital letters to the final variable we declare) It dosent occupy space in memory for multiple executions. Its good that it saves memory  2) Java final method If you make any method as final, you cannot override it. class  bird{      final   void  run(){System.out.println( "running" );}   }         class  animal  extends  bird{       void  run(){System.out.println( "animals eat birds" );}             public   static   void  main(String args[]){      animal lion=  new  animal();      animal.run();...