Why doesn’t Java autoboxing extend to method invocations of methods of the autoboxed types?

Java autoboxing/unboxing doesn’t go to the extent to allow you to dereference a primitive, so your compiler prevents it. Your compiler still knows myInt as a primitive. There’s a paper about this issue at jcp.org.

Autoboxing is mainly useful during assignment or parameter passing — allowing you to pass a primitive as an object (or vice versa), or assign a primitive to an object (or vice versa).

So unfortunately, you would have to do it like this: (kudos Patrick, I switched to your way)

Integer.toString(myInt);

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)