在Java中,冒號有多種用途:
int x = (a > b) ? a : b;
outerLoop:
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
if (i == 5 && j == 5) {
break outerLoop;
}
}
}
int[] array = {1, 2, 3, 4, 5};
for (int num : array) {
System.out.println(num);
}