About Question enthuware.ocajp.i.v7.2.1065 :
Moderator: admin
-
- Posts: 3
- Joined: Sun Oct 19, 2014 3:55 pm
- Contact:
About Question enthuware.ocajp.i.v7.2.1065 :
I would have thought that since the code that prints "4" would be unreachable, this would cause the code to not compile. I guess the compiler is not able to figure that out because the value of flag is not known until run time?
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1065 :
That is correct. flag is a variable and so its value is not known to the compiler. But even if it were a constant, the code would compile because JLS permits an unreachable if block to support conditional compilation. Please see Section 14.21 (towards the end) for details.
HTH,
Paul.
HTH,
Paul.
Who is online
Users browsing this forum: Google [Bot] and 11 guests