How many bytes does a Java integer occupy?
A: 4 bytes, a total of 32 bits1 bytes accounted for 8 bits (1B (byte) = 8 bit)Therefore, the type and byte correspond to the following byte1short2
Char 2
int 4Float 4
Double 8double 8----------------------------------------------------------------------- The following is a size output with System.out.println-----------------------------------------------------------
Byte.size //8
Short.size //16
Character.size//16
Integer.size //32
Float.size); //32
Double.size //64
Long.size //64
--------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------
Binary representation of integer negative numbers: in a computer, negative numbers are expressed in the form of a positive complement
complement = inverse code plus 1, negative number is a positive complement
Like 1:00000000000000000000000000000001.
and -1:11111111111111111111111111111111
Maximum value: 01111111111111111111111111111111 2147483647 2 of 31 square minus one
Minimum value : 10000000000000000000000000000000-2147483648 2 of 31-Time Square
--------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------
logical operators of Java >> and >>> differences>> is unsigned right shift>>> is the sign bit right shiftExample:11111111111111111111111111111100:-4
11111111111111111111111111111111: -4>>2-1
00111111111111111111111111111111: -4>>>2 1073741823
Java integers account for a few bytes, and the binary representation of negative numbers, and the difference between the logical operators of Java >> and >>>