I have been reading about autoboxing in Java. I wanted to know the difference between the below two
1) int y = 9;
Integer x = y;
and
2) Integer x = new Integer(9);
What is the difference between the above two ? I know second allocates a memory in heap. Does first case not allocate space in heap?