Something like this -
public class IntToIntegerExample {
public static void main(String[] args) {
int i = 10;
Integer intObj = new Integer(i); // Integer constructor to convert int primitive type to Integer object.
System.out.println(intObj);
}
}
int vs Integer
The main difference between two is that the 'int' type is a primitive , whereas the 'Integer' type is an object.
Object vs Primitive
Objects provide facilities for polymorphism, are passed by reference and are allocated from the heap. Whereas primitives are immutable types that are passed by value and are often allocated from the stack.