Java Introduction to data types and variables and constants
First, Java Data Type
- The Java language is a strongly typed language that defines specific data types for each data and allocates different sizes of memory space in memory.
Note: integer default: int decimal default: Double
Defines the integer type long, which needs to be followed by a number L or L; For example: long num1 = 131313L;
To define float float, you need to add F or F after the number, such as: float num2 = 3.145F;
- The size and range of memory occupied by eight basic data types
Second, variables
A storage area in memory
- Characteristics of variables
The zone has its own name (variable name) and type (data type)
Data in this region can vary from one type to the same range
- To define the format of a variable
Variable name of data type = initialization value;
Various definitions of variable writing methods:
Third, Constants
Represents a value that cannot be changed, and the declaration is often final decorated
- To define the format of a constant
Final data type constant name = initialization value
Such as: Final double pi=3.14;
Introduction to Java data types and variables and constants