the stacktrace should be printed between 'computing average' and 'exception handled in main'..... why is it getting printed at the last..irrespective of where i put the statement 'e.printStackTrace();'in the code..
compile: run: computing average exception handled in main!!! finally done in main!!! IntegerDivideByZeroErrorException at Average.computAverage(Average.java:26) at Average.printAverage(Average.java:19) at Average.main(Average.java:7) BUILD SUCCESSFUL (total time: 0 seconds)
It's difficult to understand your program, because you did not UseCodeTags.
However, I think I can guess the problem. Your code prints its messages to System.out, but uses e.printStackTrace(). The method Throwable.printStackTrace() prints to System.err.
When output is sent to both System.out and System.err, and both those streams are connected to the console (as they are by default), you will get a random intermingling of the two streams. Therefore, stuff may not appear on the console in the order that it is output by the program.
I think changing your code to say e.printStackTrace(System.out) might fix it.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.