Data types in Java are divided intoBasic data TypesAndReference Data Type:
1) The underlying data types are:Boolean, Byte, short, char, int, float, long, double. They can be divided into four types, integer, float, char, and Boolean. Byte,boolean:1 short, Char:2 int, float:4 long, double:8 all basic data types have corresponding data encapsulation types 。
integer: Byte, short, int, long occupy 1, 2, 4, 8 bytes of space respectively;
integer Type
byte
(byte type) A byte 8 bit, occupies 1 byte example 32B default is 0
The value range is -2 (7-2 (7-1 -128~127
short 16 bit, 2 byte case 32S default is 0.
The value range is -2 (15-2 (15-1 -32768~32767
int (integer) an int 32 bits, takes 4 byte example 32 default is 0
The value range is -2 (31-2 (31-1 -2147483648~2147483647
Long
(length integer) A long 64 bit takes 8 byte example 32L default is 0
The value range is -2 (63-2 (63-1 -9223372036854774808~9223372036854774807
float: Long, float occupies 4, 8 bytes respectively, Char: Char occupies 2 bytes, encoding is Unicode, the value range is/u0000~/uffff;boolean type: Boolean occupies 1 bytes.
Automatic conversion of data type: (Byte,short,char), int,long,float,double (char converted to integer, converted to corresponding ASCII code value)Byte,short,char Three types, they are lateral and therefore cannot be converted automatically to each other and can be cast using coercion. Conversion of string type to other data types:
string-"Other: string.valueof (..) Other-"String:
integer.parseint ("66891")
int i = integer.valueof ("66891"). Intvalue ();
2) Reference data type(class, interface, array)
7) Java data type