Null gets correctly cast to an Integer. Java attempts to unbox the integer into a primitive int so that it may store it in the variable, effectively calling `null.intValue()` which results in a NPE.
– MichaelDec 18 '18 at 15:28
Guys, the section below is the right place to answer, not here. Also, this is not a duplicate, because it's not about casting, but about unboxing.
– GustavoDec 18 '18 at 15:32
1
Duplicate of https://stackoverflow.com/questions/2382058/unboxing-null-object-to-primitive-type-results-in-nullpointerexception-fine , should probably be updated
– BackSlashDec 18 '18 at 15:36