First, analyze the characteristics of the basic data type, maximum and minimum values.
1,
Basic type: int bits number: +
Wrapper class: Java.lang.Integer
Minimum: integer.min_value=-2147483648 (-2 of 31 Parties)
Maximum value: integer.max_value= 2147483647 (2 of 31 square-1)
2,
Basic type: Short bits: +
Wrapper class: Java.lang.Short
Minimum value: short.min_value=-32768 (2 of 15)
Maximum: short.max_value=32767 (2 of 15 parties-1)
3,
Basic type: Long bits number: +
Wrapper class: Java.lang.Long
Minimum Value: long.min_value=-9223372036854775808 (-2 of 63)
Maximum: long.max_value= 9223372036854775807 (2 of 63 parties-1)
4,
Basic type: float bits number: +
Packing class: Java.lang.Float
min: float.min_value= 1.4E-45 (2 of-149-square)
Maximum:float.max_value=3.4028235e38 (2 128-square-1)
5,
Basic type: Double bits number: +
Wrapper class: Java.lang.Double
Minimum: double.min_value=4.9e-324 (2 to 1074)
Maximum: double.max_value= 1.7976931348623157e308 (2 of 1024 parties-1)
Second, the number of bits that can be written in the code, as proved by practice.
1, the first is the integer type
int and long can only write 10 digits, short can only write 5 numbers, more will be an error.
- int h=1234567890;
- Long w=1234567890;
- Short s=12345;
If I add a number to each of them at this point, it will be:
2. Second floating point
Float the decimal point after 6 digits, double the decimal point after 16 digits.
- float m=123.45566778465651454545f;
- Double n=3.1234567890123456789;
And then print out the result is this:
Third, episode-----The difference between int and integer
1. From the definition of int is the basic type, directly stored values (similar to float, double, String, char) integer is an object, with a reference to the object (similar to a float, double, String) 2. In terms of complexity, the data types in Java are divided into basic data types and complex data types int is the former; the Integer is the latter (that is, a Class) 3. The way the initialization is different int i = 1; The integer i= new integer (1);//integer is a class int that is a basic data type (a trace left for a process, but a useful addition to Java); An integer is a class, an extension of int, A number of conversion methods are defined note: similar to the following: float float;double double; String, where string is special and the base type is the same as a complex similar keyword. For example, when you need to put something in the Arraylist,hashmap, the built-in type such as int,double is not put in, because the container is loaded with object, which is the need for these built-in type of outer covering class. Each of the built-in types in Java has a corresponding overlay class. The int and integer relationships in Java are more subtle. The relationship is as follows:
- int is the basic data type;
- Integer is the encapsulation class of int;
- Both int and integer can represent a certain value;
- int and integer cannot be interoperable because they have two different data types;
Examples of ArrayList a_list=new ArrayList (); int n=40; Integer in=new integer (n); A_list.add (n);//error A_list.add (in);//ok
Summary: The usual accumulation is how important ah, details, details, details, or details .......... ...........
range of short, int, long, float, double values in Java