What is the number of bytes in the Java base data type? (32-bit system)BYTE 1 byte short 2 byte int 4 byte long 8 byte char 2 byte (C The language is 1 bytes) can store a Chinese character float 4 byte double 8 byte Boolean false/true (theoretically occupies 1bit,1/8 bytes, actual processing by 1byte processing)
Java is encoded using Unicode. Each byte occupies 8 bits. Your computer system should be a 32-bit system, so that each int is 4 bytes
One of these bytes consists of 8 bits
There are altogether 8 basic data types in Java (raw data types):
Type storage requirements range (inclusive) default wrapper class
Integer int 4 bytes (32 bits) -231~ 231-1 0 Integer
Number short 2 bytes (16 bit) -215~215-1 0 short
Class Long 8-byte (64-bit) -263~263-1 0 long
Type byte 1 byte (8 bit) -27~27-1 0 byte
float Float 4 byte (32 bit) -3.4e+38 ~ 3.4e+38 0.0f Float
Type Double 8-byte (64-bit) -1.7e+308 ~ 1.7e+308 0 Double
Character Char 2-byte (16-bit) u0000~uffff (' ~ '? ' 0 ' Character
(0~216-1 (65535))
Boolean boolean 1/8 bytes (1 bits) True, False False Boolean
Due to the limitations of mobile device memory in mobile development, it is often necessary to consider the number of bytes consumed by the data type used. Below is a brief introduction to some basic data types in Java to deepen your memory.
There are 8 basic data types in Java, including 4 integers, 2 floating-point types, 1 character types used to represent Unicode-encoded character cells, and 1 Boolean types that represent truth values. (one byte equals 8 bit)
1. Integral type
Type storage requirement bit number value range remark
int 4 byte 4*8
Short 2 byte 2*8-32768~32767
Long 8 byte 8*8
BYTE 1 byte 1*8-128~127
2. Floating-point type
Type storage requirement bit number value range remark
Float 4 byte 4*8 float type has a suffix f (for example: 3.14F)
Double 8 byte 8*8 floating-point value with no suffix f (for example, 3.14) defaults to double type
3.char type
Type storage requirement bit number value range remark
Char 2 byte 2*8
4.boolean type
Type storage requirement bit number value range remark
Boolean 1 byte 1*8 false, True
The number of bytes in the Java base data type