Differences between static and instance members

Source: Internet
Author: User

Static member features:

1. If there is a static keyword before a member, the member is a static member.

2. Static members can only be accessed by class name. They cannot be accessed by objects.

3. Static members are shared anywhere. After a place changes, everything changes.

4. The same memory is always used after the static method and static variable are created. You cannot directly call the instance method in the static method.

5. Static members onlyProgramWill be released only when you exit.

5. This cannot be used in static members.

6. Static classes can only contain static members.

7. You can call the static method directly in the instance method. You cannot call the instance method directly in the static method.

8. Static classes only include static members.

9. The static constructor only executes this class once when it is used for the first time.

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.