java - Why this sample code has an possible Null Pointer Access? -


why code has possible null pointer access?

    object v = (runtimeexception) null;     throw (runtimeexception) v; 

and why not?

    throw (runtimeexception) null; 

object v = (runtimeexception) null; throw (runtimeexception) v; 

compiles fine


update upon complete change in question

both of them throw npe


Comments