Data types in Java fall into 2 categories: reference data types (interfaces, classes, arrays), basic data types (four categories, total eight) 650) this.width=650; "Src=" Http://img.baidu.com/hi/jx2/j_0015.gif " alt= "J_0015.gif"/>
What is the difference between the two categories in the first analysis?
The basic data type is declared to give a memory space to store the value of the variable, whereas a reference data type declaration, like a pointer, points to an address, and the address is the stored value.
The basic data types are described below:
650) this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0001.gif "alt=" J_0001.gif "/>
Shaping: The default number of bytes
BYTE 1
Short 2
int 4√
Long 8
Floating point type:
Float 4
Double 8√
Character type:
Char 2
Boolean type:
Boolean 1
And to be aware,
In the process of the operation:
Byte, short, char will turn int to long
Float will turn into double
Byte B1=2;byte b2=4;//This is because the right side is a constant, if in the range of byte, compile will not error
Byte b3=b1+b2;//This error, because the right side is a byte type, the operation or automatic upward transformation into an int type, and the left is a byte type, large turn small, downward transformation, there will be loss of precision problems.
byte b3=2+4; This will not be an error, the reason is the same as the first, the constant addition minus, the result is a constant, if the value of the result in the byte range, will not error
This article is from the "Stone on the Road" blog, please be sure to keep this source http://xiashitou.blog.51cto.com/10853136/1946486
Data types in Java