This code just made me stare at my screen for a few minutes:
loop: for (;;) { // ... }
(line 137 here)
I have never seen this before, and I had no idea Java has a "loop" keyword (NetBeans doesn't even color it like a keyword), and it does compile fine with JDK 6.
What is the explanation?
The Java for loop is used to iterate a part of the program several times. If the number of iteration is fixed, it is recommended to use for loop.
Definition: Loops are a programming element that repeat a portion of code a set number of times until the desired process is complete. Repetitive tasks are common in programming, and loops are essential to save time and minimize errors.
It is not a keyword
it is a label
.
Usage:
label1: for (; ; ) { label2: for (; ; ) { if (condition1) { // break outer loop break label1; } if (condition2) { // break inner loop break label2; } if (condition3) { // break inner loop break; } } }
Documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With