Scotty Mitchell wrote:Well, wrappers are after all a subtype of object are they not instanceof!
I don't understand what you mean...?
The reason behind my question is that if I used StringBuilder and append then the output would be true, true because both references refer to the same object. I can understand int being immutable, but it would make more sense if Integer behaved like a regular object.
It is acting like a regular object. The think that's confusing you is the auto-boxing/unboxing, which was added to the language much later than the wrapper classes. In old-style Java:
Would be replaced by:
At which point, you probably wouldn't be surprised that aand b are referencing different objects;