Labeled statement in Java
int firstMatchValue = -1;
int[] array1 = {1, 2, 3};
int[] array2 = {2, 3, 4};
firstLoop: for (int value1 : array1) {
for (int value2 : array2) {
if (value1 == value2) {
firstMatchValue = value2;
break firstLoop;
}
}
}
//firstMatchValue is 2
- Log in to post comments