Java static's meaning!

xiaoxiao2021-03-06  111

Java static's meaning!

(J snow)? Email: zhuam@studyjava.com

I can't stand deeply in the past, I always swallow the date, maybe it is an old age (huh, :-)), now start

Slowly enter the topic, huh, huh! Everyone should know that in the Java, the statci method is not called non-Statci method, and non-STATCI.

For data members, he can only call class methods and class variables, this is a theorem, but have you thought about why? Really thought about???

Here I will do everything possible to explain STATIC, but I want to completely understand static, then first this, you have to clear, this represents

Is "current object", this is used to return a reference to the current object.

Example 01: public? Class example {???????? {???????} = i; ????} ??}

Example 02: Public class example02 {??? public void call (int i) {/ * ... * /}}}} eXample02 a = new example02 (); example02 b = new example02 (); a. Call (1); B.Call (2);

If there is only a call () method, how can it determine whether it is object A, or the object b is calling him, here the compiler is done in the dark.

A lot of things, which object you have manipulated will be passed as an important parameter to the call () method, the form of call is as follows:

Example02.call (a, 1);

EXAMPLE02.CALL (B, 2);

This is in the form of the program, we can't write this program!

If you understand the this what I said, then understanding static is not far away, Static's method does not have this method, you can't

The non-Static method is called in the Static method. The Static method allows you to call the Static method directly, don't instantiate, this is static

The purpose of the application (similar to the C language) a full-class function, but Java has no global function, and the STATIC method of the class can only be accessed.

Static method and Static data member, you can't let him send a message to the object in the Static method, because he doesn't have this.

Since my ability is limited, I have the power but still have enough, don't point out, please point out, thank you!

?

?

转载请注明原文地址:https://www.9cbs.com/read-124379.html

New Post(0)