This week's book giveaways are in the Cloud and AI/ML forums. We're giving away four copies each of Cloud Native Patterns and Natural Language Processing and have the authors on-line! See this thread and this one for details.
After line1, set has 2 values 45 & 46 represented by i1 and i2.
Now, after line2, i2 now refers to 47 ans since wrapper objects are immutable it will be a new object and will not change the value of the object added to set.
Now, at line 3 you are trying to remove object refered by i2 i.e 47, which is not there in set so nothing will be removed from set and it will give the output:
2 1 1 
add this line instead of line 12:
you will see that its returning false indicating that it is unable to find i2 with a value of 47. So confirming that 46 still remains in the collection and the rest of the explanation is same as its been told above.