Created
November 28, 2021 08:39
-
-
Save XDo0/d52b0266787b843f67bfcefcd5aec0e0 to your computer and use it in GitHub Desktop.
Java Exception
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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