1. Java Interview

Source: Internet
Author: User

1. Why use a single case instead of static

Answer: First you need to understand when static is initialized, what is the design intent, the Singleton is that we run the current virtual machine there is only one required object, there is no duplication. Static static member variables are used for the class, the properties of the class, usually some constants and so on, from the load on the class and objects, when the class is loaded into memory when the statically member variable exists, and the object does not exist, in addition to static methods can only call static methods and static variables, If all the static method, it means that the other members are also static, very inconvenient, if not a single case, it is not easy to expand, and very cumbersome.

1. Java Interview

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.