怎么用break实现跳转?
我的
public class BreakErr{
public static void main(String args[]){
outerloop:
for(int i=0;i<3;i++){
System.out.print("pass"+i+":");
}
for(int j=0;j<100;j++){
if(j == 10)
break outerloop;
System.out.print(j+"");
}
}
}
在编译时出现undefined label: outerloop 而
public class Factorial
{
public static void main(String[] args)
{
long limit = 20; // to calculate factorial of integers up to this value
long factorial = 1; // factorial will be calculated in this variable
// Loop from 1 to the value of limit
OuterLoop:
for(int i = 1; i <= limit; i++)
{
factorial = 1; // Initialize factorial
for(int j = 2; j <= i; j++)
{
if(i > 10 && i % 2 == 1)
continue OuterLoop; // Transfer to the outer loop
factorial *= j;
}
System.out.println(i + "!" + " is " + factorial);
}
}
}
却能顺利通过,那为大哥能帮以下我!