Java Personal Learning Notes: Class Properties, class methods

Source: Internet
Author: User

A class property is a variable that is shared between objects of that class. In the design phase, you analyze which class properties do not change depending on the object, and set these properties to class properties. The corresponding method is set to the class method.

If the method is not related to the caller, such a method is often referred to as a class method, which simplifies the invocation of a method because it is not necessary to create an object to invoke the class method.

Static keyword

In the Java class, you can use the static Modifier property, method, code block, inner class

After being modified members have the following characteristics:

Loaded as the class loads

Precedence over the existence of objects

Decorated members, shared by all objects

When access permission is allowed, the object is not created and is called directly by the class

Class method

You can use the class name. Method Name () to access the static tag's class method

The static property of the class can only be accessed inside the static method, and the non-static property of the class cannot be accessed.

Static is the method of the class. So the static method cannot have this

Overloaded methods require both static or non-static

Java Personal Learning Notes: Class Properties, class methods

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.