Could someone please explain this to me in clearer terms?A NullPointerException never occurs because the index expression must be completely evaluated before any part of the indexing operation occurs, and that includes the check as to whether the value of the left-hand operand is null.
About Question enthuware.ocpjp.i.v11.2.1311 :
Moderator: admin
-
- Posts: 1
- Joined: Fri Jun 26, 2020 3:59 am
- Contact:
About Question enthuware.ocpjp.i.v11.2.1311 :
-
- Site Admin
- Posts: 10046
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.i.v11.2.1311 :
While evaluating the expression a [ m1() ];, the JVM has to invoke the method m1() first. But the call to m1 throws Exception. So, before the JVM could access any element of a (which is null), it gets the Exception thrown from the call to m1. So, there is no NullPointerException.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 82 guests