Hello All,
The following code sample is taken from JQ+
The questions is if the above class will print '2' when compiled and run.
I chose true but its false
Below is the explanation given by JQ+ but its not clear to me
Explanation:
If the array reference expression produces null instead of a reference to an array, then a NullPointerException is thrown at runtime, but only after all parts of the array reference expression have been evaluated and only if these evaluations completed normally. The embedded assignment of 2 to index occurs before the check for a null pointer.
In an array access, the expression to the left of the brackets appears to be fully evaluated before any part of the expression within the brackets is evaluated.
Note that, if evaluation of the expression to the left of the brackets completes abruptly, no part of the expression within the brackets will appear to have been evaluated.
Could some one kindly clear up/explain it.
Waiting for a favorable reply.Thanks in advance.
Kind Regards.
Hasnain Javed Khan.