Summary of the third chapter of the fourth edition of Java programming ideas

1. Static import

First, a print class is defined, which has a static method print

When using, use import static before the class Manual import required

2. Java operator

3. Assignment

This special phenomenon is called "alias phenomenon", which is a basic way for Java to manipulate objects. In this example, what should I do if I want to identify names? It should read:

    t1. level = t2. level;

I don't quite understand the following sentence:

This keeps the two objects independent of each other, rather than binding T1 and T2 to the same object. But you will soon realize that directly manipulating the domain of objects can easily lead to confusion and violate the principles of good object-oriented programming. This is not a small problem, so from now on, you should note that assigning values to objects may produce unexpected results.

My question: what is the result? Suppose that the member variable is not a basic type, but a reference type. If you assign a value to a reference type and point to another address, the place where the reference address is used will be affected. I understand this. I don't know, right

Alias phenomenon in method calls. That is, the parameter is a reference type and the reference address is passed Once the member variable of the reference address is modified inside the method, all points to the reference address will be modified

4. Automatic increment and decrement

Memory methods and operations are all + 1. If Mr. becomes a value, it is generated before + 1. Later generated values are generated after operation, so + 1

Output results:

5. Equivalence of objects

6. Truncation and rounding

fasdfasdf

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>