循环标签跳出循环
public class GotoTest { public static void main(String[] args) { int[][] array={ {1,20,3}, {28,90,10}, {60,46,71,100}, {41,420,43} }; outer: for (int rowIdx = 0; rowIdx < array.length; rowIdx++) { for (int columnIdx = 0; columnIdx < array[rowIdx].length; columnIdx++) { System.out.print(array[rowIdx][columnIdx]+" "); if (columnIdx>2) { break outer; } } System.out.println(""); } System.out.println("End"); } }
Output:
1 20 3 28 90 10 60 46 71 100 End