One: Java data types have basic data types, reference data types
Two: 8 Basic data types:
1. Integer type: Byte, Short,long
2. Floating-point data type: float,double
3. Character type: Char
4. Boolean Type: Boolean
A. The default type of integer type is int
B. Define a long type of data, which must be appended with L or L
C. Floating-point number type, the default data is double
D. Define data of type float. You have to add F and f to the data.
E.double, you can add D or D after the data. is generally omitted
F.char represents a character type, and the data is placed in ' value ' when the value is assigned
G.string represents a string type, and when assigned, the data is placed in "value"
Three: Steps to use a variable
First step: Declare variables, both "In memory request space based on data type"
Data type variable name; int money
Step Two: Assign values to "store data in the corresponding memory space"
Variable name = value; money=1000;
The first and third steps merge
Data type variable name = value; int money=1000;
Step three: Use variables to both remove data using
Four: Variable name specification
1. The first letter of the variable name must be a letter, underscore, dollar sign, the rest of the numbers, letters, underscores, dollar signs
2. Short can clearly indicate the role of the variable, usually the first word of the initial capital letter
3. Variables are declared and assigned before they can be used
4. Declaring two variables of the same name cannot be duplicated
Five. Scope of the variable
From defining the variable place to the end of the current "}", the variable will be recycled if it is out of scope
VI: Basic data type conversions
1. Automatic type conversion (implicit type conversion): From small to large types can be automatically completed
2. Coercion of type conversions: large-to-small types require a cast character, resulting in loss of precision or overflow
Byte-->short-->int-->long-->float-->double
From left to right small type to large type, can be automatic type conversion
To the left large type to small type, you need to force type conversion
Java data types and definitions of variables