![](/img/trans.png)
[英]Why a method main.replay() is not getting executed in Java? But exactly the same code works in Fedora not in Archlinux
[英]Why is main method not getting called same no. of times recursively in java every time it is executed?
当我试图运行这个程序几次的最终值i
是11407
, 11417
, 11400
显示堆栈溢出错误之前等。 为什么每次执行该程序时i
的最终值都不相同?
public class MainRecursive {
static int i=0;
public static void main (String arg[])
{
i++;
System.out.println(i);
main(arg);
}
}
尝试添加System.out.flush();
印刷后。
由于堆栈大小没有变化,每次运行时我得到相同的值,但我认为println()
在异常更新输出之前被异常中断 - 这取决于控制台,操作系统等而不能是确定性的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.