`

java 构造函数,while 循环标识

    博客分类:
  • java
阅读更多

java 构造函数只有在类new的时候才执行

 

2. What will happen when you attempt to compile and run the following code?
 public class Selby{
int i=0;
public static void main(String argv[]){ //没有执行任何代码
}
Selby(){
top:
while(i<2){
System.out.println(i);
i++;
continue top;
}
}
}

A) Compile time error, a target label cannot come before the matching

continue or break statement.
B) Compilation but no output at runtime
C) Compilation and output of 0
D) Compilation and output of 0 followed by 1

 

B是正确的

 

 

 

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics