Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package dudasForo;
- public class Ejemplo_RuntimeException {
- private void exceptionGenerator() throws RuntimeException {
- while (true) {
- if ((int) (Math.random() * 100) < 90) {
- System.out.println("Tarea X correcta");
- } else {
- throw new RuntimeException("Tarea X con error");
- }
- }
- }
- private void exec() {
- try {
- exceptionGenerator();
- } catch (Exception e) {
- System.out.println(e.getMessage());
- }
- }
- public static void main(String[] args) {
- new Ejercicio19_JavierAlbaranez().exec();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement