1. Four integer types (byte, short, int, long)
byte: 8 bits, used to represent the smallest data unit , such as the data in the file, -128~127
short: 16 bits, -32768 ~ 32767
int: 32 bits, -2^31-1~2^31 (2.1 billion)
long: 64 bits
2. Two floating point types (float, double)
float: 32 bits, suffix F or f
double: 64 bits, the most commonly used, suffix D or d
3. A character type (char)
char: 16 bits, an integer Type, 1 character enclosed in single quotes (can be a Chinese character)
Note: It cannot be 0 characters.
Escape characters: \n Line feed \r Carriage return \t Tab character \" Double quotation marks \\ represents a \ Two characters char are connected with " " in the middle. The characters are first converted to int type internally, and then For addition operations, char is essentially a number! Binary, when displayed, is "processed" and displayed as characters.
4. A Boolean type (boolean)
true and false
5. Type conversion
char--> Automatic conversion: byte-->short-->int--> ;long-->float-->double through Exceeding the value range
Recommended tutorial:
Java tutorialThe above is the detailed content of What are the basic data types in Java. For more information, please follow other related articles on the PHP Chinese website!