The final Java keyword

class

  1. When the final modification class, which can not be inherited
    a. final modification of the class member variable can be varied according to actual needs
    b. Method final modification of the members of the class for the final default method

method

  1. The modified final methods can not be overridden.
    a. private method implicitly designated as a final method
    b. If the parent class has a method final modification, the override can not go subclass.

Member variables

  1. It must be given an initial value, and only once during initialization.
    . a member of the fianl modified variable assignment, there are two ways: direct assignment or all of the initial value in the constructor.
    b. If modified member variable is a primitive type, then the value of this variable can not be changed.
    c. If the modified member variable is a reference type, it is said that the value of the referenced address can not be modified, but the reference to the object pointed inside the content or can be changed.
Published 15 original articles · won praise 2 · Views 569

Guess you like

Origin blog.csdn.net/weixin_42170152/article/details/104222530