Advertisement
virtualideaz

TryCatchFinally.java

Mar 26th, 2015
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. public class TryCatchFinally {
  2.  
  3.     public static void main(String[] args) {
  4.        
  5.         try {
  6.                 System.out.println("Try block before the error");
  7.                 System.out.println(1/0);
  8.                 System.out.println("Try block after the error");
  9.             }
  10.         catch (ArithmeticException e)
  11.             {
  12.                 System.out.println("Catch Block");
  13.                 System.out.println("A stack trace of the error");
  14.                 e.printStackTrace();
  15.                 System.out.println("The operation is not possible");
  16.             }
  17.         finally
  18.             {
  19.                 System.out.println("Finally Block");
  20.             }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement