About Question enthuware.ocajp.i.v7.2.1105 :
Moderator: admin
-
- Posts: 63
- Joined: Fri Oct 31, 2014 6:31 pm
- Contact:
About Question enthuware.ocajp.i.v7.2.1105 :
Why is not compiler complains about unreachable code here?
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1105 :
The compiler specifically makes an exception for an if statement.
final static boolean DEBUG = false;
if(DEBUG){
//ideally, this block is unreachable but the compiler allows it.
}
The reason is explained here: http://docs.oracle.com/javase/specs/jls ... #jls-14.21 (at the end)
HTH,
Paul.
final static boolean DEBUG = false;
if(DEBUG){
//ideally, this block is unreachable but the compiler allows it.
}
The reason is explained here: http://docs.oracle.com/javase/specs/jls ... #jls-14.21 (at the end)
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: Google [Bot] and 201 guests