Article From:



Starting date: 2018-03-24



  • finalThe function is to make the modified variables, methods or classes “fixed and final”, so that the modified variables, methods and classes can no longer be changed.
  • finalClasses, methods, variables can be modified.
  • finalThe modified class can not be inherited.
  • finalThe modified method can not be overwritten (rewritten)image
  • finalThe modified variable is a constant, and the final modified variable must be explicitly initialized and can only be initialized once. The initialization can be directly declared and assigned, or can be assigned in the initialization block or constructor, or the formal parameter is passed.
  • finalCan not coexist with abstract interface, because final modified classes cannot be inherited and rewritten
  • finalModifier reference variable: the internal data can be modified, but the object that is directed can not be modified







If an internal class is to use a local variable,Only local variables that are modified by final can be accessed only:

The life cycle of local variable is different from the inner class. When the local variable is modified by final, the variable modified by final becomes the data member in the internal class.

(JavaUsing a copy local variable (copy of local variables) way to achieve that is defined as a local variable final copy, and references can also take over with, just can’t re assignment. Thus it is possible to create a acceSS local variable (access local variables) of the illusion, but this time due to the re assignment, it is generally not unexpected things happen.)image_5ab533d8_4c16



Link of this Article: Java:final keyword

Leave a Reply

Your email address will not be published. Required fields are marked *