daily pastebin goal
63%
SHARE
TWEET

Untitled

a guest Mar 25th, 2019 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package dudasForo;
  2.  
  3. public class Ejemplo_RuntimeException {
  4.  
  5.     private void exceptionGenerator() throws RuntimeException {
  6.         while (true) {
  7.             if ((int) (Math.random() * 100) < 90) {
  8.                 System.out.println("Tarea X correcta");
  9.             } else {
  10.                 throw new RuntimeException("Tarea X con error");
  11.             }
  12.         }
  13.     }
  14.  
  15.     private void exec() {
  16.         try {
  17.             exceptionGenerator();
  18.         } catch (Exception e) {
  19.             System.out.println(e.getMessage());
  20.         }
  21.     }
  22.  
  23.     public static void main(String[] args) {
  24.         new Ejercicio19_JavierAlbaranez().exec();
  25.     }
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top