This is a code snippet which Im worried about
Which will be the first line to cause an error in the following code?
1 class Char
2 {
3 public static void main(
String arg[])
4 {
5 while(false)
6 {
7 System.out.println("Hello");
8 }
9 while(false)
10 {
11 }
12 do;
13 while(false);
14 do
15 {
16 ;
17 }
18 while(false);
19 }
20 }
answer is Line no. 5 statement not reached
1)why the compiler throws error why doesnt it skip the first while as it evaluates to false n move on to the next line?
2) Will line no 12 and 13 form a do while loop.if it does then the semicolon
after do doesnt give error why?
3)when line no 5 and 9 is replaced by while(true), line no 9 and 12 gives
unreachable statement error.Why?
Thanks in advance to all those who rack their head for a solution!1
regs -Rajesh Chandra