Skip to content

Instantly share code, notes, and snippets.

@XDo0
Created November 28, 2021 08:39
Show Gist options
  • Save XDo0/d52b0266787b843f67bfcefcd5aec0e0 to your computer and use it in GitHub Desktop.
Save XDo0/d52b0266787b843f67bfcefcd5aec0e0 to your computer and use it in GitHub Desktop.
Java Exception
class ExceptionOperations{
try
{
//...
}
catch (ArithmeticException e)
{
System.out.println(e.toString());
}
catch (ArrayIndexOutOfBoundsException e)
{
System.out.println(e.toString());
}
catch (Exception e)
{
System.err.println("Caught Exception");
System.err.println("getMessage():" + e.getMessage());
System.err.println("getLocalizedMessage():" + e.getLocalizedMessage());
System.err.println("toString():" + e);
System.err.println("printStackTrace():");
e.printStackTrace();
}
finally {
System.exit(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment