Looping Statements Doesn’t loop?

August 10th, 2008 | by Drew |


Image Source: www.pragprog.com
Did you know that looping statements doesn’t loop the whole if-else statement if you put an if-else statement in the looping statement? That’s right. Looping statements only goes through the if-else statements once. Once the looping statement activates the statements inside the if-else statement, the looping statement will only loop the statement inside the if-else statement. That is why it is not recommendable to use if-else statement inside a looping statement, such as do-while statements, while statements, and for statements. The only thing I recommend for you to use a switch statement. Looping statements reads the whole switch statement, possibly because switch statements requires a specific value for a condition. I don’t really know, but it works. Don’t worry. Switch statement also has a “Default” statement inside it that works just like the “else” statement in the if-else statement. The only disadvantage is that you won’t be able to set comparisons like greater than (») or less than («).

Sorry, comments for this entry are closed at this time.