First, basic grammar

1. The comments

Single-line comment // Comment content Multi-line comment /* Comment content */ Document comment /** Comment content */ Comment nesting: Multi-line comment can be nested single-line comment cannot be nested multi-line commentCopy the code

2. Key words

True, false, and NULL are not Java keywords, although they cannot be used for variable naming eitherCopy the code

2. Basic data types

1. Basic types

Integers: bytes, short, int, long (default: int) Floating point: single precision (float), double (default: double) Character types: Booleans encoded with Unicode character sets: Some static attributes of each data TYPE: MAX_VALUE(maximum),MIN_VALUE(minimum),TYPE(TYPE),SIZE(SIZE) Cannot assign a primitive TYPE to a stringCopy the code

2. Default values for data types

Byte :0 short:0 int:0 long:0L Float :0.0F double:0.0D char: null character,’\u0000′ Boolean :false Reference data type :null

Variables and constants

1. Variable type conversion

When any primitive type is concatenated with a string, the value of the primitive type is converted to a string. The String String is a reference type, not a base typeCopy the code

2. The constant

Final Data type Variable name [= value] Variable names are usually capitalizedCopy the code

2.1 the integer

Binary octal decimal hexadecimal systemCopy the code

2.2 Floating point constants

Standard decimal scientific counting method 1.2e+6, 5e-8Copy the code

2.3 Character Constants

Common character Escape character Unicode characterCopy the code

2.4 String Constants

2.5 Boolean constants

There are only true and false valuesCopy the code

2.6 the null constant

There is only one value, null, indicating that the object reference is nullCopy the code

Operator. Operator

1. The division operator

Both operands of a division operation are integers, and the quotient is an integer. If one of the operands is a floating point number, the quotient is also a floating point numberCopy the code

2. Take the modulo operator

The positive or negative of the result is the same as the dividend regardless of the divisorCopy the code

3. Assignment operators

When assigning a value to a variable, casting is required if the type is incompatible. When assigning a value using an extended operator, casting is done automaticallyCopy the code

4. Relational operators

(1) All relational operators except == support only comparison of numeric types. (2) Comparison of numeric types requires only comparison of numeric types. (4) Boolean types cannot be compared with other types. (5) Reference types do not inherit from each other, nor can they be compared using ==Copy the code

5. Logical operators

The result of the logical operator is Boolean ^: xor, false if the operands are the same, true if they are differentCopy the code

5. Program structure

The label must be defined before the outer loop of the loop in which the break occurs to make sense.Copy the code