Core Java I Reading notes

Source: Internet
Author: User
Tags pow

Static keyword:

We all know the static modifier, which means that the corresponding variable or method is common to an instance of this class, and it is not necessary to create an instance of the class to access it.

eg.  public static final Double PI = 3.14 ... Can be obtained directly through Math.PI.

Front of all good understanding,static method always some do not understand, the following focus on learning static Mathod:

  The Static methods is methods that does not the operate on objects. For example, Math.pow (A, b) is called on the Math class, not Object.

you can think of static methods as methods that don ' t has a this parameter. in a nonstatic method, the this parameter refers To The implicit parameter of the method.
a static method can access a static feld. But cannot access the fields of the instance.

use static methods in both situations:

? When a method doesn ' t need to access the object state because all needed parameters is supplied as explicit para Meters (example: math.pow).
? When a method is only needs to access static Felds of the Class (example: employee.getnextid).

Factory Method:


Core Java I Reading notes

Related Article

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: 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.