How many bytes does int, char, and long occupy?

Number of bytes occupied by Java primitive types:
1 byte: byte , boolean
2 bytes: short , char
4 bytes: int , float
8 bytes: long , double

Encoding and Chinese:
Unicode/GBK: Chinese 2-byte
UTF-8: Chinese is usually 3 bytes, after the expansion of the B area is 4 bytes
In summary, the number of bytes occupied by Chinese characters in the encoding is generally 2-4 bytes.

 

Short in C language is usually 2 bytes, which may be related to the platform compiler.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324521266&siteId=291194637