【发布时间】:2013-11-07 14:59:49
【问题描述】:
我在 Eclipse 中键入了一个简单的算术程序。在 Eclipse 中运行程序时,每次运行时输出都会以奇怪的顺序出现。有时异常出现在最后 print 语句首先出现(这是正确的方法)。有时它以混乱的顺序出现,反之亦然。为什么会发生以及如何纠正它?每次执行时是否有任何设置可以使其以正确的方式打印。下面的屏幕截图显示了它的外观。请帮我解决这个问题。
正确顺序:
我们运行几次后的顺序不正确
package com;
public class Abc {
/**
* @param args
*/
public static void main(String[] args) {
System.out.println("begin main");
// TODO Auto-generated method stub
int a = 10;
int b = 0;
int c = 0;
System.out.println("value of a BD is " + a);
System.out.println("value of b BD is " + b);
System.out.println("value of c BD is " + c);
c = a/b; //Arthmetic Exception
System.out.println("value of a AD is " + a);
System.out.println("value of b AD is " + b);
System.out.println("value of c AD is " + c);
}
}
【问题讨论】:
-
当监视器发表这样的评论时,如果他们发布指向重复项的链接将会很有帮助。
标签: java eclipse exception eclipse-juno