first that is the basis of this program you must to know that
Integer is immutable
now you can see figure when 47 value pass it does not go to object that contains 1 value , it create new block of 47 means object in memory same as
String work.
now when you used i2 in remove(i2) it refer to new object that contains value 47 but set has not 47 so it return null and nothing is removed from set .
i think this picture will help you.