Advertisement
lamaulfarid

ExeptionHandlingTryCatchFinally

Dec 23rd, 2020
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.56 KB | None | 0 0
  1.  
  2. /**
  3.  * Class untuk penanganan error dengan try, catch dan finally keyword
  4.  *
  5.  * @author Ahmad Lamaul Farid
  6.  * @version 24 Desember 2020
  7.  */
  8.  
  9. public class Main
  10. {
  11.     public static void main(String[] args) {
  12.         try
  13.         {
  14.             int[] myNumbers = {1, 2, 3};
  15.             System.out.println(myNumbers[10]);
  16.         }
  17.         catch (Exception e)
  18.         {
  19.             System.out.println("Something went wrong.");
  20.         }
  21.         finally
  22.         {
  23.             System.out.println("The 'try catch' is finished.");
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement