Variable, data type and type conversion, variable data type conversion
Objective: To master basic java syntax knowledge
1 variable
Variable is the amount in change, and the value in the variable is changed. in java, you must declare the variable when using the variable, and declare the variable name when declaring the variable, A variable name must be a sequence of letters or numbers starting with a letter. The length of the variable name is unlimited. When naming a variable, only one word is in lowercase. If there are more than two words, the first word is in lowercase and the first letter of the other words is in upper case. The variable name cannot use keywords in java.
2 Data Type
Integer 2.1
Java is a strongly typed language, which means that a type must be declared for each variable. There are eight basic types in java, four of which are Integer type and two floating point type, one character type.
Data Type: (1) Basic data type (2) Reference Data Type
Basic data types: numeric, char, and boolean)
Numeric: INTEGER (byte, short, int, long), floating point (float, double)
(2) reference data types: class, interface, and array
Logical boolean
Boolean data can only be set to true or false. The value cannot be 0 or an integer other than 0 instead of true or false.
Text char
A character constant is a single character enclosed in single quotes. It adopts the unicode encoding format. One character occupies two bytes.
INTEGER (byte, short, int, long)
Char occupies 2 bytes
Short from-32768 to 32767
Int from-2147483648 to 2147483647, a total of 10 digits
From-9223372036854775808 to 9223372036854775807, a total of 19 characters long
Three Forms of Integer constants in java
Decimal INTEGER: for example, 13,-204,0.
Octal INTEGER: must start with 0, for example, 014.
Hexadecimal number: it must start with 0x or 0X, for example, 0X14.
Float and double)
Java floating-point type constants can be expressed in two forms
Decimal number format: for example, 3.45.
Scientific Notation: for example, 2.34e2