Java Basic Detail Record
The index of Java is not the case starting from 0:
The format parameter index is starting from 1, not 0:system.out.println (%1 $ s%2$s, "Test:", "OK");
In Java, when using the while loop, be careful to endless loop, because while is when the meaning, it is easy to stop the condition without stopping the operation can not be terminated;
Each case in a switch in Java needs to have a "break;" and the default statement is used to handle any case other than the case; And the case label must be an integer or enumeration constant;
String equals (), disables "= =", except (string A = = null); The = = Comparison of string is a comparison of storage addresses, and if strings are obtained by stitching or other operations, there will be inconsistencies, so you cannot use them to avoid the occurrence of bugs:
e.g.
1 Public Static voidMain (string[] args) {2 //TODO auto-generated Method Stub3 4String A = "AB";5String B = "A";6String C = b + "B";7 if(A = =C) {8System.out.println ("A==c is true");9 }Ten One if(A.equals (C)) { ASystem.out.println ("A equals B is True"); - } -}
Output:a equals B is true;
Constant declaration: final (constant is not recommended for reserved keywords)
operation of double type note: 2.0-1.1=0.8999999 ...
operator with self-decrement: use note because the order of updates and operations affects the final result
confusion of bitwise operators and relational operators:
"|, &, ^, ~" and "| |, &&,!"
Conversion of numeric types:
Countless data loss conversions
BYTE---------long
|--> Double <--Float
CHAR-to-int
There is data loss
int---> FLOAT <---long---> Double
Methods of the Math class:
Math.Round implementation rounding;
Java.math.XXXX compare cattle break;
Copy assignment:
The assignment of an object is the assignment of a reference, and if the copy is modified, the reference points to the content being modified, causing the entire object value to change, and if the other single assignment statement is only a single aspect of the value change does not affect each other;
Commonly used statement writing:
Condition?expression1:expression2;
for (type Para:paraset) {}
Java Learning (2)