Aniruddh Joshi wrote:Thanks Rob.
If I get it right now I can cast any object to a primitive.
Only if the object is a primitive wrapper of the right type (Integer + int, Long + long, etc). Otherwise the compiler won't complain but you'll get a ClassCastException. That's because line 12 is actually a cast to Integer, then auto unboxing: