Java Reference
In-Depth Information
// First, define a label at the beginning of your loop.
Translate_loop:
for (x = 0; x < ARRAY_SIZE ; x++) {
int inputMsgSize = errorMsgs[x].msgSize;
if (inputMsgSize == 0) {
// Find the next item with some text. Then move its text into this
// item's text.
for (y = x + 1; y < ARRAY_SIZE ; y++) {
inputMsgSize = errorMsgs[y].msgSize;
if (inputMsgSize != 0) {
errorMsgs[x].setErrorMsg
(errorMsgs[y].getErrorMsg);
break;
}
else {
if (y == (ARRAY_SIZE - 1)) {
// You are on the last item, without finding text. Exit the translate
// loop entirely.
// Do not process any more items.
break Translate_loop;
}
}
}
}
// Translate the error message.
errorMsgs[x].setErrorMsg
((errorMsgs[x].getTranslation()));
}
// This statement will be processed as the next statement after
// break Translate_loop; is executed.
// It is also performed as the next statement after the loop exits
// normally.
System.out.println ("The loop has completed");
Table 7.1 summarizes the Java flow control operators.
Search WWH ::




Custom Search