Also, another example I thought of would be below. Am I right in thinking there are two Integer objects created (one for 6 and one for 7) ? and would that mean that after the "y++" line, there is one object that is garbage collector eligible (i.e. new Integer(6))
This is going to be confusing -- you have too many things going on here.
Yes, the Integer(6) does get created -- as you created it yourself.
Yes, autoboxing will reassign the reference to a Integer(7). But, this object won't be created, as it already exist in the integer cache (which autoboxing uses).
Yes, the Integer(6) will be eligible for GC -- as it didn't come from the cache.
or would it not be eligible because they are like immutable (like Strings are).
There is no relationship between immutability and eligible for GC. Strings are immutable and they can be eligible for GC.
Henry