Why is the string class in Java final?

Source: Internet
Author: User

Today in the "Graphic design mode", there is a problem "the string class with the final decoration, so that it can not be inherited (extended), which violates the open and closed principle, what is the justification for doing so?" ”

The answer is efficiency and security .

The first is efficiency, because the string class is basically one of the most frequently used classes, and if used poorly, there is a noticeable performance problem. So I made it into the final class altogether. There are many optimizations that can be done in the JVM (such as being reused in stacks), similar to StringBuilder,

String[str??] DetailXBasic TranslationN. Line, string, line Vt. To make a row, string, stretch, straighten VI. To form a string of N. (String) name of person; (DE) Sterling; (Sweden) SterlingNetwork explanationString: String Quartet: String Quartet string instrument: stringed instrument

Why is the string class in Java final?

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.