Java for Reading Notes, java for Reading Notes
Expression puzzles
"Odd
When the remainder operation is performed, a non-zero result is returned. It has the same positive and negative symbols as the left operand.
Zero puzzles
Avoid using float and double where exact answers are needed. For currency operations. Use int, long, or BigDEcimal.
Long division
When you are building a large number, you must never let it go-he is a silent killer.
If you are not sure, you can use the long operation to execute the entire computation.
Preliminary questions
In the literal length of the long type, the L must be capitalized;
Multiple Transformations
If the initial numeric type is signed, the symbol extension is executed. If it is a char, the 0 extension is executed no matter what type he wants to convert. Do not use the composite value assignment operator for byte, short, or, char.
Character puzzles
To convert a char array to a String, call the String. valueOf (char []) method.
When using string Concatenation Operators, we always enclose extraordinary operators in parentheses. (+ Operator priority is greater than =)
, Do not use Unicode escape characters unless necessary.
Loop puzzles
Do not assign values to the same variable more than once in a single expression.
An exception
Never use return break to exit the finally statement block.
To handle any errors that may be thrown in the finally statement block, rather than spreading them.
Do not use exception control loops. Only Exception conditions should be used.
CATEGORY puzzles
Each static field shares a single copy of its class and all its sub-classes.
Never use an expression to identify a static method. Do not hide static methods.
The instanceof operator is defined as false if its left operand is null.
Using a variable to create an instance
Other puzzles
Do not add 0 to the front of an integer literal constant. This will change it to an octal value.