---restore content starts---
Type
Basic type
Types of Java
Reference type
Basic type
shaping (Byte, short, int, long)
floating-point type (float, double)
character Type (char)
Boolean Type (Boolean)
Plastic
Bit (bit): either 0 or 1
Byte (byte): 8 bit.
2^0 2^4=>16 2^5=>32 2^6=>64 2^7=>128 2^8=>256 2^9=>512 2^10=>1024 (K)
2^11=>2048 2^12=>4096 2^16=>65536 2^20=>m 2^30=>g (1 billion) 2^40=>t
Byte:8 bit (can represent 256 numbers), Value range: -128~127
Short:16 bit (can represent 65,536 numbers), Value range: -32768~32767
Int:32 bit (can represent 4G number), Value range: -2g~2g-1
Long:64 bit (large range of values, no memory required)
Note the point:
A, you directly give an integer, the integer default is the int type.
If the integer value is small, and is directly assigned to byte or short, Java can also treat it as a byte and a little bit.
B, if you give a huge integer directly, Java does not automatically treat it as a long type.
If you want Java to treat the integer as long, you need to add L or L after the integer.
C, Integer A total of 4 forms of expression:
Decimal:
Octal: Starting with 0
Every 8 in 1, can only appear 0~7.
Hex: Starts with 0 x or 0x.
Every 16 into 1, can only appear 0~9, a~f.
Binary: Starts with 0 B or 0b
Every 2 in 1, can only appear 0~1
Hexadecimal numbers, which are very common in programming--each hexadecimal number is exactly converted to a 4-bit binary number, so it's very handy
---restore content ends---
Java Basic Types