首页 > 试题广场 >

下面程序的输出是? public class Main

[单选题]
下面程序的输出是?
public class Main {
  public static void main(String[] args) {
    Other o = new Other();
    new Main().addOne(o);
    System.out.println(o.i);
  }
  public void addOne(final Other o) {
    o.i++;
  }
}

class Other {
  public int i;
}

  • 0
  • 1
  • 编译出错
  • 运行出错
求解
发表于 2021-02-22 00:40:11 回复(0)