Current location - Loan Platform Complete Network - Big data management - Number of bytes for each variable in java
Number of bytes for each variable in java

boolen: 1 byte

int: 4 bytes

float: 4 bytes

double: 8 bytes

char: 2 bytes

byte: 1 byte

short: 2 bytes

long: 8 bytes

Extended information

Java 8 basic data types

1, the four integer types (byte, short, int, long):

byte: 8-bit, used to represent the smallest unit of data, such as the data in the file, -128~127

short: 16-bit, rarely used, -32768 ~ 32767

int: 32-bit, most commonly used, -2^31-1 ~ 2^31 ? (2.1 billion)

2, two types of floating-point numbers (float, double):

float: 32-bit, suffixed by F or f, 1 sign bit, 8 exponent bits, 23 effective mantissa.

double: 64-bit, most commonly used, suffix D or d, 1-bit sign bit, 11-bit exponent, 52-bit effective tail.

3, a character type (char): ?

char: 16-bit, integer type, 1 character enclosed in single quotes (can be a Chinese character), use Unicode code to represent characters, 0~2^16-1 (65535).?

4, a boolean type (boolean): true true and false false

Reference link: Baidu Encyclopedia JAVA