Java Modifier Summary

<tbody>
    <tr>
      <td><b>Modifier</b></td>
      <td><b>Used on</b></td>
      <td><b>Meaning</b></td>
     
      </tr>
   <tr valign="top">

    <td>abstract</td>
    <td>class<br><br>
        interface<br><br>
        method<br><br></td>
    <td>Contains unimplemented methods and cannot be instantiated.<br><br>
        All interfaces are abstract. Optional in declarations<br><br>

        No body, only signature. The enclosing class is abstract</td>
     
   </tr>
    
   <tr valign="top">
    <td>final<br></td>
    <td>class<br><br>
        method<br><br>
        field<br><br>

        variable<br><br></td>
    <td>Cannot be subclassed<br><br>
        Cannot be overridden and dynamically looked up<br><br>
        Cannot change its value. static final fields are compile-time constants.<br><br>
        Cannot change its value.<br></td>
     
   </tr>

   <tr valign="top">
    <td>native<br></td>
    <td>method</td>
    <td>Platform-dependent.
        No body, only signature<br></td>
     
   </tr>
   <tr valign="top">
    <td>none(package)<br></td>

    <td>class<br><br>
        interface<br><br>
        member<br><br></td>
    <td>Accessible only in its package<br><br>
        Accessible only in its package<br><br>
        Accessible only in its package<br><br></td>

     
   </tr>
    <tr valign="top">
     <td>private<br></td>
     <td>member<br></td>
     <td>Accessible only in its class(which defins it).<br></td>
      
    </tr>
    <tr valign="top">

     <td>protected<br></td>
     <td>member<br></td>
     <td>Accessible only within its package and its subclasses</td>
      
    </tr>
    <tr valign="top">
     <td>public<br></td>
     <td>class<br><br>

         interface<br><br>
         member<br><br></td>
     <td>Accessible anywhere<br><br>
         Accessible anywhere<br><br>
         Accessible anywhere its class is.<br><br></td>
      
    </tr>

    <tr valign="top">
     <td>strictfp<br></td>
     <td>class<br><br>
         method<br><br></td>
     <td>All methods in the class are implicitly strictfp.<br><br>
         All floating-point computation done is strictly conforms to <br>

         the IEEE 754 standard. All values including intermediate results<br>
         must be expressed as IEEE float or double values. <br>
         It is rarely used.<br><br></td>
      
    </tr>
    <tr valign="top">
     <td>static<br></td>
     <td>class<br><br>

         method<br><br>
         field<br><br><br>
         initializer<br><br></td>
     <td>Make an inner class top-level class<br><br>
         A class method, invoked through the class name.<br><br>
         A class field, invoked through the class name <br>

         one instance, regardless of class instances created.<br><br>
         Run when the class is loaded, rather than when an instance is created.<br><br></td>
      
    </tr>
    <tr valign="top">
     <td>synchronized<br></td>
     <td>method<br></td>
     <td>For a static method, a lock for the class is acquired before<br>

         executing the method. For a non-static method, a lock for the specific<br>
         object instance is acquired.<br><br>
         </td>
      
    </tr>
    <tr valign="top">
     <td>transient<br></td>
     <td>field<br></td>

     <td>Not be serialized with the object, used with object serializations.<br></td>
      
    </tr>
    <tr valign="top">
     <td>volatile<br></td>
     <td>field<br></td>
     <td>Accessible by unsynchronized threads, very rarely used.<br></td>
     </tr> 
   
</tbody>

你可能感兴趣的:(java,UP)