Advertisement
xlujiax

Excepciones

Jul 4th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 KB | None | 0 0
  1. package ejemplo;
  2.  
  3. public class Ejemplo1 {
  4.  
  5.     public static void main(String[] args) {
  6.         // TODO Auto-generated method stub
  7.         int j = 0;
  8.         String cadena = null;
  9.         try {
  10.             System.out.println("Longitud de la cadena "+cadena.length());
  11.            
  12.             j = 1/j;
  13.             System.out.println("Pasamos por la división");
  14.         } catch (ArithmeticException e) {
  15.             System.out.println("Capturamos el error de la división");
  16.         } catch (NullPointerException e) {
  17.             System.out.println("Exception Null");
  18.         } catch (Exception e) {
  19.             System.out.println("Exception ");
  20.         } finally {
  21.             try {
  22.                 System.out.println("Longitud de la cadena "+cadena.length());
  23.             } catch (Exception e) {
  24.                 System.out.println("Exception 2 Null");
  25.             }
  26.             System.out.println("Reto Cumplido!");
  27.         }
  28.         System.out.println("Seguimos con el Programa");
  29.     }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement