In-depth understanding of Java static

Source: Internet
Author: User

Static is mainly used to modify filed and methods.

The static decorated member indicates that it belongs to the class itself and not to a single instance of the class, in other words, the static decorated property is a public property (a property that all objects can use)

The static modification method has the following limitations:

Static defined methods cannot call non-static methods or properties, and non-static defined methods can invoke static properties and methods.

The main reasons are:

1 methods that use static-defined properties can be used when an object is not instantiated

2 properties and methods that are not static defined must be instantiated before the object can be used


In-depth understanding of Java static

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.