outer多用于嵌套循环的情况
1 outer: 2 for (int i = 2 ; i <= 10 ; i++) 3 { 4 5 for (int j = 2 ; j <=10 ; j++) 6 { 7 8 if(i != 2 && j % i== 0) 9 { 10 continue outer; 11 } 12 } 13 System.out.println(i+n); 14 }
View Code
满足内层循环中if条件时需要跳出到外层循环,此时便需要使用outer,相当于goto.
转载于:https://www.cnblogs.com/vinozly/p/4764754.html