Java variable sizes
1. byte: Occupies 1 byte and stores whole numbers from -128 to
1271.
2. short: Requires 2 bytes and holds whole numbers from -32,768 to
32,7671.
3. int: Takes up 4 bytes and stores whole numbers from -
2,147,483,648 to 2,147,483,6471.
4. long: Utilizes 8 bytes and accommodates whole numbers from -
9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 1.
5. float: Requires 4 bytes and stores fractional numbers. It’s sufficient
for storing 6 to 7 decimal digits1.
6. double: Occupies 8 bytes and also stores fractional numbers. It’s
sufficient for storing 15 decimal digits1.
7. boolean: Consumes 1 bit and stores true or false values1.
8. char: Takes up 2 bytes and stores a single character or ASCII
values1.