Data that can be allocated directly in the stack is the base data type. Reference data type: the reference to the data is in the stack, but his object is in the heap.
Basic data type, small size turn large, big turn to be smaller will lose precision
First Class: Logical Type Boolean
Type II: Text Char
Class III: Integer type (byte, short, int, Long) class fourth: float (float, double)
Integer has a byte short int long char, denoted by 8, 16, 32, 64, 16bits, respectively. In some places, char may not be included in an integer category, but essentially a char type is a subset of Int.
A byte short int long is signed, denoted by the 2 complement (s-complement). Char, in 16-bit notation, is unsigned and represents the UTF-16 encoding set.
A byte is represented by a 1-byte 8-bit, which is the smallest integer type. Mainly used to save memory space key. The byte type is particularly useful when manipulating data flows from networks, files, or other IO. The values range from: [-128, 127].
Shortwith -bit, the value range is:[-2^15, 2^15-1]. ShortIt's probably the least common type. Shortwhen the type participates in the operation, the same is promoted tointor a higher type. Int bits, [-2^31, 2^31-1].a signed binary complement represents an integer. Long + bits,[-2^63, 2^63-1,The default value is0L].When you need to calculate a very large number, ifintinsufficient to accommodate size, can be usedLongtype. IfLongis not enough, you can useBigIntegerclass. Char [ 0, 65535], [0, 2^16-1],from' \u0000 'to the' \uffff '. Unsigned, the default value is' \u0000 '. JavaUseUnicodeCharacter sets represent characters,Unicodeis the complete national a character set that can represent all the characters in a human language. Unicodeneed to -bit width, soJavain theChartype is also used- bitrepresentation. WhenCharwhen the subtraction operation is performed, it is also converted tointtype, you must explicitly convert it back. floatUse+ bitindicates that the corresponding single-precision floating-point number, compared to the operating speedDoublefaster, takes up less memory, but becomes imprecise when the value is very large or very small. Can be used when the accuracy requirement is not highfloattypedouble64to indicate that a floating pip face is assigned to a variable if it is not displayed after the literal value andForF, the default isDoubletype. Java.lang.Mathare used in the functions inDoubletype. ifDoubleand thefloatcannot achieve the desired accuracy, you can useBigDecimalclass. Booleantype has only two valuestrueand thefalse, the default isfalse. Booleanand whether it is0There is no relationship, but you can convert according to the logic you want. Automatic Conversion a larger type, such asint) to save a smaller type, such asbyte), memory is always sufficient and does not require a cast. Forcing type conversions If you want to turn the big into small, or in Shortwith theCharmust be cast, also known as a narrowing conversion (Narrowing Conversion),because the numeric value must be explicitly smaller to accommodate the target type.
JAVA second day basic data type