Does anyone knows what the group_skip
do?
Maybe it is a basic programming, but I've been programming using Java for some years and just found it today.
group_skip: do {
event = stepToNextEvent(FormController.STEP_OVER_GROUP);
switch (event) {
case FormEntryController.EVENT_QUESTION:
case FormEntryController.EVENT_END_OF_FORM:
break group_skip;
}
} while (event != FormEntryController.EVENT_END_OF_FORM);
Thanks!
The break statement is frequently used to terminate the processing of a particular case within a switch statement. Lack of an enclosing iterative or switch statement generates an error.
The break statement terminates the current loop, switch , or label statement and transfers program control to the statement following the terminated statement.
The break statement is used to terminate the loop immediately. The continue statement is used to skip the current iteration of the loop. break keyword is used to indicate break statements in java programming. continue keyword is used to indicate continue statement in java programming.
When the break statement is encountered inside a loop, the loop is immediately terminated and the program control resumes at the next statement following the loop. It can be used to terminate a case in the switch statement (covered in the next chapter).
This is a labelled loop, when break group_skip;
statement is executed, it will jump out of the do while loop which is labelled as group_skip
boolean isTrue = true;
outer: for (int i = 0; i < 5; i++) {
while (isTrue) {
System.out.println("Hello");
break outer;
} // end of inner while
System.out.println("Outer loop"); // does not print
} // end of outer loop
System.out.println("Good Bye");
This outputs
Hello
Good Bye
You can get the concept clear here.
for
loop called outer
and there is inner while
loopbreak outer;
statementouter for loop
has a System.out.println"Outer loop"
statement but that does not get printed.break outer
causes the control to jump out of labelled for
loop directlyNow this example for continue
statement
outer: for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
System.out.println("Hello");
continue outer;
} // end of inner loop
System.out.println("outer"); // this won't print
} // end of outer loop
System.out.println("Good bye");
This prints
Hello
Hello
Hello
Hello
Hello
Good bye
for
loop here and an inner for
loopfor
loop prints Hello
and continues to the outer
loop.for
loop are skipped and outer
loop continues to execute.outer
for loop, Good Bye
is printedHope this makes everything clear.
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