Eight kinds of basic data types:
four kinds of shaping: byte, Short), int, Long
2 Species floating point types : float, double
character of Unicode characters is one kind of units: char
. 1 in a Boolean : boolean
8 bits and bytes occupied by the type and in the following ranges:
Types of | Occupancy bytes | Occupancy digit | Numerical length |
---|---|---|---|
byte | 1 | 8 | -128 to 127 (-2 to 7 th to 7 th -12) |
short | 2 | 16 | -32768 to 32767 (the 15th power of -2 to the 15 th -12) |
int | 4 | 32 | -2147483648 2147483647 ~ (-2 31 th to the 31 th -12) |
long | 8 | 64 | (~ -9,223,372,036,854,774,808 9223372036854774807) (- 63 to 63 th -12 th power of 2) |
float | 4 | 32 | (1.401298e-45 ~ 3.402823e + 38 ) (e-45 minus 45 is multiplied by the power of 10, e + 38 is multiplied by 10 ^ 38 ^ 128) (power of 2 to 2 -149 -1) |
double | 8 | 64 | (4.9000000e-324 ~ 1.797693e + 308) (-1074 th power of 2, power of 1024 - 2) |
char | 2 | 16 | |
boolean | 1 | 8 |
1 byte = 1 byte = 8bit
Second, the difference episode ----- int and an Integer
1. By definition
int is the basic type, direct deposit value (also similar to float, double, String, char)
Integer is an object with a reference point to the object (like there are Float, Double, String)
2. Initialize different ways
int i =1;
Integer i = new Integer (1); // integer is a class
int is the basic data type (Process-oriented traces, but is a useful complement to the java); Integer is a class, int is extended, it defines a number of conversion methods
Note: There are similar: float Float; double Double; String, among String more special, the same basic type and complexity of similar keywords.
For example, when it is necessary to put things ArrayList, HashMap in like int, double this is not put into the built-in type, because the container object is loaded, which is built needs to these types of classes of the outer cover. Each type has a built-in Java respective class of the outer cover.
Java, int and Integer relationship is more subtle. Relationship is as follows:
- int is the basic data types;
- It is a wrapper class int Integer;
- int Integer and may represent a certain value;
- int and Integer can not interoperable, because they are two different types of data;