80 What is the difference between PrintStakeTrace, toString, getMessage in Exception Handling in Java?

Code:

package com.ca.atharva;
class Demo
{

static void m1()
{
try
{
System.out.println(" try block ");
int a = 10 / 0;
}
catch(Exception e)
{
System.out.println(" catch block \n\n ");
System.out.println( e.toString()+"  \n\n " );
e.printStackTrace();
System.out.println("  \n\n "+ e.getMessage() );
}
finally
{
System.out.println("  finally block ");
}

}
public static void main( String args[] )
{
m1();
}
}



Output:



Previous
Next Post »