2.java Basic Syntax
Java basic syntax and C language have many similarities, because Java ' as a rising star, borrowed a lot of C, C + + syntax
1. The keyword goto and const can not be used in Java, is to facilitate the conversion of C and C + + to Java code, if the conversion of C and C + + contains these two words will be reported compilation error
Three reserved words false true null
2. Identifiers
1. Identifiers cannot be keywords and reserved words
2. Can only contain alphanumeric underscore and dollar sign $
3. Cannot start with a number
4, case-insensitive, no length specified
The rules of the rule
First Letter Lowercase
Variable name first letter lowercase lower first letter of Word uppercase
Constant names are all uppercase, and multiple words are separated by underscores
3. data type, variable name, constant
Basic data type: Integer (Byte, short, int, long) character type (char) float (float, double) Boolean (Boolean)
Reference data type: Array interface (interface) classes (class)
Variables: Define a piece of memory space in your computer that can change data
Constant final modified constant name reason: 1, easy to modify 2, the business meaning with people data value
4. Operators and expressions
Short-circuit Calculation && | | No short circuit Calculation & |
Shift Operation 4<<1 =8
Java Learning Summary--2. Basic syntax