posted 23 years ago
hi sonir,
this is because of the exception catching and throwing mechanism.
[] has higher priority than =. so ml() will be first called to evaluate the index of the array (dont care yet that whther array has been allocated memory or not).
ml() throws exception which is forwarded to the calling point that is in main() method. and we have main() method not catching that exception but declares to "throw" an exception.
thus it throws the exception further which JVM has to handle now and so JVM exists after handling the exception and u never reach at the point when the array element evaluated by the m1l() call gets resolved and u try to access the member a[ml()].
so, u don't get NullPointerException.
regards
maulin