1. Java Comment: single-line comment, multiline comment, document comment
Document comments: Execute Javadoc, generate HTML-formatted code reports;
Multi-line annotations do not allow nesting.
2. Identifier naming specification
Package name: all words lowercase;
Class name Interface name: All words capitalized in the first letter;
Variable name and function name: The first word is lowercase and the first letter of each word is capitalized;
Constant name: All words capitalized, each word underlined ' _ ' connection.
Note: The keyword cannot be an identifier;
Keyword all letters lowercase.
3, negative number of binary: Take the reverse plus one
4. Data type
Basic data types: Byte, short, int (integer default), long, float, double (decimal default)
Char
Boolean
Reference data type: class, interface, []
Note: Data type conversions
Short num = 9= num + 10;
Compile error, 10 default to int type, ' = ' data type inconsistent, need to cast
num = (short) (num + 10);
Attention:
Short num = 9+ = 10;
The compilation was successful because it was converted automatically.
"Programing in Java" explains:
Q. is there any difference between a + = b and a = a + b, where a and b are PR Imitive types?
A. possibly, if A and b are of different types. The assignment statement A + = b is equivalent to a = (int.) (A + B) if a is of type I NT. Thus, if b is of type double, a + = b are legal, but a = a + b is a compile-time Error.
5. String connector, addition operator
Note: string data and any data are connected with ' + '
1 Public classHello2 {3 Public Static voidMain (string[] args)4 {5 intA = 4, B;6b = a++;7System.out.println ("a =" + A + ", B =" +b);8SYSTEM.OUT.PRINTLN ("AB =" + A +b);9System.out.println ("a + b =" + (A +b));Ten } One}
6. Shift
>>: Fill the vacancy with the sign bit
>>>: with 0 fill vacancies
"Java Fundamentals" June 9