Ishu_15hu

Java Nested Exception Handling

Apr 17th, 2021
538
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /******************************************************************************
  2.  
  3.                             Online Java Compiler.
  4.                 Code, Compile, Run and Debug java program online.
  5. Write your code in this editor and press "Run" button to execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. import java.util.Arrays;
  10. import java.util.Scanner;
  11.  
  12. public class Riya{  
  13.  public static void main(String args[]){
  14.     Scanner sc=new Scanner(System.in);
  15.    
  16.     try{
  17.         int a[]=new int[5];
  18.         System.out.print("Enter values: ");
  19.         for(int i=0;i<5;i++) a[i]=sc.nextInt();  
  20.        
  21.         try{
  22.             int divider;
  23.            
  24.             System.out.print("Enter divider: ");
  25.             divider = sc.nextInt();
  26.            
  27.             System.out.println(a[3]/divider);
  28.         }
  29.         catch(Exception e){
  30.             System.out.println(e);  
  31.         }
  32.     }
  33.     catch(Exception e){
  34.         System.out.println(e);
  35.     }
  36.  }
  37. }  
  38.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×