final, as well as public, protected, (default), private rights modifier summary

Package cn.learn.Final;
 / * 
   when used to modify the final class 
   1 can not have any subclass of the class, none of these members overwritten, but can override the parent class 

   when used to modify the final Method 
   1. The the method can not be overwritten 
   2 but can not be used simultaneously, and abstract, an abstract method is not a method, contradictory 

   when used to modify the final local variables 
   1. this variable is not changed, the same life time assignment 
   Note: for basic types, values can not be changed 
      for reference types, the address value can not be changed, 
      EG: Phone = Final MyPhone Phone ( "Apple") 
      MyPhone Phone new new = ( "HUAWEI") can not be used, myPhone address values can not be changed 
      while myPhone.setName ( "huawei" ); set name can be 

   when used to modify the final member variables 
   1. Since the member variables have default values (empty / false), if a final modification, must be assigned 
   2. If direct assignment, all overloaded constructor, must final modified variable assignment 
 * / 

/ * 
         when java rights modifier modifying 
           public> protected> (default)> private
The same class: YYYY 
    1.private can access other can access 
the same package: YYYN 
different packages is a subclass: YYNN 
    1. Take for example a sub package 
extraordinary package already sub-categories: YNNN 

Note: default is not a keyword, not write 
 * /

 

Guess you like

Origin www.cnblogs.com/huxiaobai/p/11470271.html