¡GoConqr estrena diseño! Cuéntanos qué te parece.

Apuntes

Sin título

Amanda McCauley Inglés 1 página

Contenido del apunte (1)

Página 1

Exception handling

•An

exception is an event that occurs during the execution of the program that

disturbs the normal flow of instructions.

e.g. An invalid data type has been entered, accessing an array with an index that is too large/small, opening a file that cannot be found etc.

When exceptions happen the usual result is a crash.... unless they are handled.

•There

are two aspects of dealing with program errors:

Detection: Identify

the type of problem.

Handling: Handle

the problem to avoid crash/other issues.

Java has 'exception classes' which deal with all the different exceptions.

IOExceptions, ClassNotFoundExceptions, RuntimeException

•Exception handling operates by:

Trying to run a procedure that might cause

an error then having

a method that Catches an error condition and “throws an exception”.

If

you write a segment of code in which something might go wrong then you can

place it in a try block:try {

//the

statements that might result in

//an exception

} catch (Exception anException) {

//action to

take if exception occurs

}

Información

Descripción
Apunte sobre Sin título, creado por Amanda McCauley el 20/03/2017.
Creado por
Amanda McCauley
Visitas
0
Valoración

Escríbenos

¿Sobre qué es tu mensaje?

¿Qué te parece el nuevo diseño?

¿Te gusta?