java learning day10 - final keyword

final keyword

    final is a keyword representing the final.

    

    final modified class can not be inherited; final modified method can not be overridden (coverage ), but can be inherited

      

      Looking at the example, first final class : direct error in the inheritance

       

       

 

 

      Longer final modification of the parent class method: class can be inherited, but this time when the error method overrides

      

      

 

       

      Once the final modified variable is assigned can not be assigned again .

      

 

       Here we must say something, Final and static when used with a definition of a constant, constant name must be all uppercase letters

 

 

      final modification of reference, once refers to an object in the future can no longer point to other objects

        Look no final modification:

        

    

 

        Then there is a final modification:

        

 

 

 

      

      

 

 

 

 

 

   

      

Guess you like

Origin www.cnblogs.com/javaisbest/p/11600858.html
Recommended