填空题:当编译运行下列代码时,运行结果是什么?
当编译运行下列代码时,运行结果是什么?
public class Main{
public static void main(String args[]){
outer:
for(int i=0;i<3;i++){
innner:
for(int j=0;j<3;j++){
if(j>1) break outer;
System.out.println(j+" and "+i);
}
}
}
}
运行结果:
答案:
第1空:0 and 0 ||
第2空:1 and 0 ||
public class Main{
public static void main(String args[]){
outer:
for(int i=0;i<3;i++){
innner:
for(int j=0;j<3;j++){
if(j>1) break outer;
System.out.println(j+" and "+i);
}
}
}
}
运行结果:
答案:
第1空:0 and 0 ||
第2空:1 and 0 ||