Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

对于以下Java代码的运行结果描述正确的是( ) public class Test { private static final int flag=1; public static void main(String[] args) { for(inti=0;i<100;i++){ System.out.println(flag++); } } } #59

Open
waylau opened this issue Jul 4, 2020 · 0 comments

Comments

@waylau
Copy link
Owner

waylau commented Jul 4, 2020

对于以下Java代码的运行结果描述正确的是( )

public class Test { 
  private static final int flag=1; 
  public static void main(String[] args) { 
    for(int i=0;i<100;i++){ 
      System.out.println(flag++); 
    } 
  }
}

A. 程序运行100次,分别输出0到99
B. 程序运行101次,分别输出0至100
C. 程序编译错误
D. 程序可能出现死循环

你的回答A 是错误的。预计是C,因为flag是final,不能修改

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant