ControlProgramStream
1. Print the output
Print strings and numbers using the print statement of the corresponding data type (basic type)
For example:
Int I = 10;
Float F = 10.9f;
Printint ("INTEGER:", I );
Printfloat ("float:", F );
Random Rand = new random ();
Int I;
Double D;
Long L;
I = Rand. nextint ();
D = Rand. nextdouble ();
L = Rand. nextlong ();
2. Regular Expression
Regular Expressions are a method used to describe strings in general terms.
To express a number, there may be no negative number. You can follow a question mark after the negative number:
-?
To represent an integer, you can describe that it has one or multiple digits. In a regular expression
'/D'
You can use () to group expressions.
For example:
I> J is (true | false)
The "|" here indicates the logic and. Indicates that the string is false if it is not true.
For other characters, exact matching is required as long as they are not special characters specific to regular expressions.
However, in Java, strings must be escaped.
For example, j = -? /D + in Java is J = -? // D +
J + k = -? /D in Java is J/+ k = -? // D
3. The equals () method must be used for string comparison.
4. The equals () method compares references.
For example:
Clsaa value {
Int I;
}
Public class test {
Public static void main (string [] ARGs ){
Value V1 = new value ();
Value v2 = new value ();
V1. I = v2. I = 100;
System. Out. println (v1.equals (V2 ));
}
}
The result is false. To get the desired comparison method, you can only reload the equals () method in the new class.
5. logical operators can only be used for boolean values.
6. Short Circuit.
For example, if (A & B & C), if there is a value of false, the remaining expressions are not judged.
7. The shift operator can only process integer types.
"<" Left Shift Operator: Move the operator object on the left to the specified number of digits on the right of the operator, and add 0 at the low position;
">" Signed right shift operator: Move the operator object on the left of the operator to the right to the specified number of digits on the right of the operator. If the symbol is positive, insert 0 at the high position; otherwise, insert 1;
">>>" Unsigned right shift operator: No matter whether positive or negative, 0 is inserted at the high position.
8. During Shift processing on char, byte, and short, it is automatically converted to int before the shift, and the result is also Int.
The right operand can only be the lower five digits in its binary. This is to prevent removal from the int range.
If it is long, the right operand is 6 lower digits in its binary.
9. When you perform the unsigned right shift assignment operation on Byte and short, the possible value is incorrect. Because it is first converted to int, then shifted, then truncated, and finally converted back to its own type.
The result may be-1.
10. Any basic data type can be converted to another basic type, except the boolean type.
11. When performing arithmetic or bitwise operations on the basic data type, all the twists and turns will be converted to int. Type conversion is required to give a small type.
12. The expressions in condition judgment can only be logical expressions.
13. Tag and break, continue
Label1:
Outer-iteration {
Inner-iteration {
Break; // 1
Continue; // 2
Continue lable1; // 3
Break label1; // 4
}
}
1: Break interrupts the internal loop and returns to the External Loop;
2: Move back to the internal loop;
3: interrupt the internal and external loops, switch to label1, and continue the loop, but start from the External Loop again;
4: Like 3, the loop is no longer executed.
Such a combined application can be used to exit the entire loop without exiting the method.
14. Only int (short, byte) and char types can be used in the switch (integral-Selector.
15. The output range in math. Random () is [0, 1 ).