Think in Java Reading Notes (3)

xiaoxiao2021-03-06  99

This chapter mainly summarizes the basic functions and grammar of Java. The following aspects should pay attention to:

1. The assignment of the object: When you assign object a to object B, it is actually replicated his reference to B, in fact, the value stored in the B is not stored in the memory address stored in the associated value, which assigns the value. Afterward, when the value in A changes, the value in B will change. Therefore, the main Equals () function is used.

2. i and i : i is incremented in the fore sequence, that is, the calculation is then rebuilt, i is increasing, that is, the value is first assigned; - I and I - are also the same.

3. Note that short-circuiting is a short-circuit approve: For example, FUNCA () && funcb () && funcc () is determined, if FUNCB does not satisfy the condition, the program will jump out, and FUNCC will not execute.

4. Mandatory conversion of types: For example, the INT type I can convert the INT type I to L again to the LONG type L; the general Class type is not allowed to be transformed, but it can be done by special approach (subsequent) Objects in the same class can be transformed between the objects in the same class.

5. Getting of random letters: Math.random can generate a value between 0, 1, multiply the random number of random numbers in the range (alphabetic 26), plus an offset, can be obtained.

Example: char c = (char) (Math.random () * 26 'a');

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

New Post(0)