Manejo de Errores y Excepciones

Las excepciones permiten detectar y controlar errores durante la ejecución de un programa.


try y catch

try permite ejecutar código que puede generar errores y catch permite capturar las excepciones.

Ejemplo 1

try{

}catch(Exception e){

}

Ejemplo 2

catch(ArithmeticException e){

}

Ejercicios


throw, throws y finally

throw y throws permiten generar excepciones y finally ejecuta instrucciones obligatorias.

Ejemplo 1

throw new Exception();

Ejemplo 2

finally{

}

Ejercicios

Volver al inicio