Variable overview
-
What is a variable?
The amount by which the value can change within a certain range during program execution -
Variable definition format
Data type variable name = variable value -
Why define variables
to store constants of the same type continuously, and can be reused
type of data
-
Why have data types? The
Java language is a strongly typed language. For each type of data, a clear specific data type is defined, and different sizes of memory space are allocated in the memory. -
Classification of data types in Java
Basic data types
Reference data types -
Basic data type
integerKeyword size range byte One byte -128~127 short Two bytes -2^15 ~ 2^15 - 1 int Four bytes -2^31 ~ 2^31 - 1 long Eight bytes -2^63 ~ 2^63 - 1 Floating point
Keyword size range float Four bytes -3.403E38 ~ 3.408E38 double Eight bytes -1.798E308 ~ 1.798E308 Character type
Keyword size range char Two bytes 0~65535 Boolean
Keyword size range boolean No clear size true、false