Join Peggy Fisher for an in-depth discussion in this video Handling errors, part of Learning Java.
- Most programming languages have code…that helps handle unexpected errors.…It provides the programmer control over the exception…so they can provide meaningful messages…and avoid program interruptions.…As you saw when we were working on our file examples,…we added a try-catch block of code…to handle a file exception error.…We placed this in our code…in areas that might cause an exception.…When an error occurs, an exception is thrown, or raised,…which is then caught by the exception handler.…
The exception handler can be used for catching file errors…as well as some logic errors.…For example, divide by 0.…Let's take a look.…I have open here an error handling project.…I start out by declaring count as 0.…My intentions were that count would be…the number of values that I'm adding up,…so I can find the average.…But as you can see, I forgot to ever add anything to count.…I declare x, y, and z as integer values,…I add them together and divide by count,…and put that value into average,…and then I print it out.…
You can also see that there's no errors…
- Downloading and exploring NetBeans
- Understanding Java basics: data types, strings, arrays, and more
- Controlling flow with functions and loops
- Creating classes
- Sorting and searching arrays
- Manipulating files
- Handling errors
- Building GUIs
Skill Level Beginner
1. Getting Started
2. Java Basics
3. Flow of Control
4. Classes and Objects
5. Beyond the Basics
6. File Manipulation
7. Graphical User Interface Basics
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.