GoConqr has a new look! Let us know what you think.

Notes

Untitled

Amanda McCauley English 1 page

Content of the notes (1)

Page 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

}

Information

Description
Note on Untitled, created by Amanda McCauley on 20/03/2017.
Created by
Amanda McCauley
Views
1
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?