1. The large aspect of int and integer is the difference between the basic data type and its wrapper class:
int is the basic type, the value is stored directly, and the integer is the object, with a reference to that object, which is a complex data type.
2. When initializing:
The variable of int is initialized to NULL as a variable of 0,integer.
int i =1;integer i= new integer (1); integer is a class that is an extension of int that defines a number of conversion methods.
3. Also similar are the float float;double double;string string, and int other constants and methods that are useful when handling types.
4. Note: When you need to store something in the hashmap,arraylist, like int,double, this type is not put in, because the container is loaded with object, which requires these built-in type of outer covering class.
5. The relationship between the two:
Integer is the encapsulation class of int;
Both can represent a value, but they are not interoperable because the two data types are different;
For example:
ArrayList a=new ArrayList ();
int i=10;
Integer n=new integer (1);
A.add (i);//Not allowed
A.add (n);//Can
Note: int is not supported when defining a generic type.
In summary: int knowledge is used to do some subtraction operations or to pass as parameters. If you want to work like an object, you need an integer to declare an object.
int and Integer in Java