I am confused as to why Integer and int can be used interchangeably in Java even though one is a primitive type and the other is an object?

For example:

Integer b = 42;
int a  = b;

Or

int d = 12;
Integer c = d;
Edit
Report