Java final class, javafinal class

Source: Internet
Author: User

Java final class, javafinal class

If the entire class is final (with the final keyword prefixed by its definition), it means that you do not want to inherit from this class, or do not allow anyone else to take this operation. In other words, for one reason or another, we certainly do not need to make any changes to the class; or for security reasons, we do not want to subclass (subclass processing ). In addition, we may also consider execution efficiency and want to ensure that all actions involving all objects of this class are as effective as possible.

/*** Created by xfyou on 2016/11/2. * final class demo *///! Class Further extends din1_ur {}// error: Cannot extend final class 'dinateur 'public class Jurassic {public static void main (String [] args) {din1_ur n = new din1_ur (); n. f (); n. I = 40; n. j ++ ;}} class SmallBrain {}final class din1_ur {int I = 7; int j = 1; SmallBrain x = new SmallBrain (); void f (){}}

 

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.