A small anomaly. Could you please explain it, kind sir? Thank you very much.

by kpkmd54461 on 2012-02-11 11:49:03

---------------------------- Why no error prompt without adding a `while` loop!? ------------ What is the reason? ------ Solution -------------------------------------------------------- That's because your `while` loop is an infinite loop. Due to the infinite loop, the code below it will never be executed, meaning the code below is unreachable. ------ Solution -------------------------------------------------------- IDE performs basic checks on code logic. If you use `while (true)`, the logic represents an infinite loop. In this case, the statements below it are impossible to execute. The IDE performs basic logical checks for you to prevent some unexpected coding issues. ------ Solution -------------------------------------------------------- You can figure out what's going on by using breakpoint debugging. Once the program enters the `while` loop, it won't exit, as you've written an infinite loop. How could there be no problem? This applies to Oracle stored procedures as well. ------ Solution -------------------------------------------------------- Your statement in the loop is an infinite loop, so the statements below the loop will never be executed. Eclipse will check the logic of your code. For example:

```java

while (true) {

System.out.println("in loop");

if (1 == 1) {

System.out.println("will do break");

break;

}

}

System.out.println("out loop");

```

If you want to avoid such compilation errors, include a statement in the loop that allows you to exit the loop, as shown in the example above. ------ Solution -------------------------------------------------------- There is no statement in the `while (true)` condition to break out of the loop, so the subsequent module becomes unreachable. ------ Solution -------------------------------------------------------- For reference: [ ] Please help explain the following code:

http://www.myexception.cn/c-sharp/64339.html

Related topic articles:

- A multiple-choice question and its solution approach

- Oracle batch query data resolution idea

- Questions about setting up the Android-2.0.1 development environment