Advertisement
Ishu_15hu

Java Nested Exception Handling

Apr 17th, 2021
649
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.01 KB | None | 0 0
  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.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement