Why are there data types
The Java language is a strongly typed language that defines specific data types for each data.
Different sizes of space are allocated in memory
Classification of data types in Java
Basic data types
Reference data type
Basic data type Classification (class 4, type 8)
Integer type
Byte occupies one byte
Short occupies two bytes
int occupies four bytes
A long occupies eight bytes
Floating point Type
Float occupies four bytes
Double takes eight bytes
Boolean type
Boolean
Theoretically occupies one-eighth bytes, but Java does not explicitly specify his dih
1 classDemo1_datatype {2 Public Static voidmain{3 4 byteb =10;5 Shorts = 20;6 Longx = 40;7 Longx = 88888888L;//The default value is int, and the range of values above int will be error, plus L or l8 floatf = 1.2f;9 DoubleD = 5.4;//the default type for decimals is double, and float is followed by F or FTen One System.out.println (b); A System.out.println (s); - System.out.println (i); - System.out.println (x) the -}
Overview and classification of basic Java language data types