In Ava, the keyword final encoding is used

Source: Internet
Author: User
1. The final class cannot be inherited. Therefore, the member methods of the final class have no chance to be overwritten. By default, they are all final. When designing a class, if the class does not need a subclass, the implementation details of the class cannot be changed, and the class will not be extended, it is designed as a final class. 2. If a class does not allow its subclass to overwrite a method, the final method can be declared as the final method. There are two reasons for using the final method: first, lock the method to prevent any inheritance class from modifying its meaning and implementation. Second, efficient. The compiler transfers the final method to the embedded mechanism to greatly improve the execution efficiency. 3. The final variable (constant) uses the final modified member variable to represent the constant. Once given, the value cannot be changed! Three final-modified variables are available: static variables, instance variables, and local variables, representing three types of constants respectively. As shown in the following example, the final variable value cannot be changed once it is given. In addition, when final variables are defined, they can be declared first without initial values. In this case, variables are also called final blank, no matter what the situation is, the compiler ensures that the blank final must be initialized before use. However, the final blank space provides greater flexibility in the use of the final keyword final. For this reason, the final data members in a class can be implemented based on objects, but there are features that keep them unchanged. 4. When the final parameter is of the final type, you can read and use this parameter, but the value of this parameter cannot be changed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.