1. Data types in Java
Data type: base type and reference type
Basic type: Numeric, character, Boolean
Numeric: integer types and floating-point types
Reference type: Class, interface, array
Basic data types
Four class/Eight class basic types are defined in Java
Boolean----Boolean
Character type----Char
Integer type----byte,short,int,long
Floating-point type----float,double (all basic types in Java have a fixed storage range and the amount of memory space they occupy without being affected by the specific operating system, thus ensuring Java portability)
2. Integer type
Type takes up storage space storage range
BYTE 1 byte-128 ( -2^ (8-1)) ~-127 ( -2^ (8-1)-1)
Short 2 bytes -2^ (16-1) ~-2^ (16-1)-1
int 4 bytes -2^ (32-1) ~-2^ (32-1)-1
Long 8 bytes -2^ (64-1) ~-2^ (64-1)-1
Float 4 bytes
The Java-language integer constant defaults to int, to declare long can be added ' L ' long i=3l
In Java, floating-point constants default to double type, to declare a constant float type such as float i=3f
Boolean type for logical operations, generally for program flow control
Boolean type data only allows values of true and False
3. Conversions between basic data types are divided into four types
Automatic type conversions: small-capacity types are automatically converted to large-capacity data types (char,byte,short,--long--float--double,) with the addition of a forced conversion character
Forcing type conversions
The Boolean type cannot be converted to any of its data types
Java Beginner Java language main knowledge point three