Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is the unreachable code?

 
Simo Hayha
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the unreachable code?
i tried the following code:
if(false){int i=0;}
it is compiled successful
but when i tried the following code individually:
for(int i=0;false;i++){int j=0;}
while(false){int i=0;}
it can not be compiled!
so what's the unreachable code?
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please have a look at JLS 14.20 Unreachable Statements
In a nutshell, if(false) is tolerated to allow conditional compilation. for(;false ; ) and while(false) are not allowed by the compiler.
[ August 16, 2002: Message edited by: Valentin Crettaz ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic