Java has eight basic types, Byte, char, short, int, long, float, double, and Boolean, respectively.
BYTE: Byte type, which occupies a byte of 8 bits. is a signed type, and the highest bit is the sign bit, which indicates a range of-128-127. The wrapper class is Byte.
Char: Character type, accounting for 2 bytes. Unsigned type, size range is 0-65535. Packing class for character
BYTE differs from char: char can be a table Chinese character, Byte is not available.
Short: Shorter integer, two bytes, size range -215-+215-1. The packing class is short.
The default integer type in Int:java, which is 4 bytes, and the size range is -231-+231-1. The wrapper class is an integer.
Long: The length of the shape, accounting for 8 bytes, the size range is -263-+263-1. The wrapper class is long.
float: Floating-point type (single precision), accounting for 4 bytes. The packing class is float.
Double: Dual type (double), 8 bytes, default floating-point type in Java. The wrapper class is double.
Boolean: Boolean, logical Judgment, two values: true, False. The wrapper class is a Boolean.
Usage Experience:
1. Forced type conversions are required to convert a type that represents a larger range or higher precision to a type with a smaller range or lower precision.
2.byte,char,short,int four basic types and their wrapper classes (which require java5.0/1.5 or later) can be used with switch statements .
3. when using the + 、-、 *,/, and% operators to perform operations on the base type , the two operands first consider whether one is of type double, if so, the other and the result will be converted to a double type. In this regard Float,long, two operands (including Byte, short, int, char) will be converted to the int type;
When you use the + =,-=, *=,/=,%=, and operators to perform operations on the base type, the value to the right of the operator is first cast to the same type as the left-hand value of the operator, and then the operation is performed with the same result as the left numeric type of the operator.
Java Basic Types