我有一个在Eclipse中编写的简单算术程序。每次我在Eclipse中运行程序时,输出结果都以奇怪的顺序出现。有时异常会在最后一个打印语句之前出现(这是正确的方式),有时则相反,以混乱的顺序出现。为什么会发生这种情况,如何纠正它?是否有任何设置可以使其每次执行时以正确的方式打印。下面的屏幕截图显示了它的外观。请帮助我解决这个问题。
正确顺序:
在运行几次后的错误顺序:
正确顺序:
![Correct Order when run](https://istack.dev59.com/82rcD.webp)
![Incorrect Order](https://istack.dev59.com/ogvBz.webp)
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);
}
}