In mobile development, due to the limitations of the memory of mobile devices, you must consider the number of bytes occupied by the data type. The following describes several basic data types in Java to deepen the memory.
There are a total of eight basic data types in Java, including four integer types and two floating point types, one character type is used to represent the character units of Unicode encoding and one boolean type used to represent the true value.
1. Integer
Value range remarks for type storage requirements
Int 4 bytes
Short 2 byte-32768 ~ 32767
Long 8 bytes
Byte 1 byte-128 ~ 127
2. Floating Point Type
Value range remarks for type storage requirements
A float 4-byte float value has a suffix F (for example, 3.14f)
The double 8-byte floating point value without the suffix F (for example, 3.14) is of the double type by default.
3. Char type
Value range remarks for type storage requirements
Char 2 bytes
4. boolean type
Value range remarks for type storage requirements
Boolean 1 byte false, true