Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

e.printStackTrace() problems ?

807598Jul 21 2006 — edited Jul 21 2006
Hi All,

Recently I have been trying out exception printing and ran across strange behaviour. I just noticed that e.printStackTrace() actually prints the message at the end of everything...... does any body know why ?
----------------------------------------
here is my code...
------------------------------------------

public class ExceptionTrial
{
	public static void main( String arguments[] )
	{
		try
		{
			int i=1;
			i=i-1;
			int b=3/i;
		}
		catch (Exception e)
		{
			System.out.println( "\nprintStackTrace Should Start here------\n" );
			e.printStackTrace();

			System.out.println( "\nprintStackTrace Should End here------\n" );
		}
	}
}



---------------------
The result
------------------------


printStackTrace Should Start here------


printStackTrace Should End here------

java.lang.ArithmeticException: / by zero
				at ExceptionTrial.main(ExceptionTrial.java:10)
????????????????? Why is it printing the message at the end ???????????
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 18 2006
Added on Jul 21 2006
24 comments
2,578 views