Exercises, examples and other material relating to training module J712. This topic is presented on public courses Learning to Program in Java
, Java Bootcamp
, Java Programming for the Web
Your program is affected by the environment around it. Its performance will vary depending on aspects as diverse as user inputs and the availability (or lack) of a network service. Java provides you with exceptions, which are a mechanism through which you trap and handle behaviours that differ from the norm.
Related technical and longer articleserrors v exceptions
|Articles and tips on this subject||updated|
|4396||Java Utility class - flexible replacement for array. Also cacheing in objects and multiple catch clauses example.|
In Java, utility class objects are used as flexible alternatives to arrays to hold collections of other obejcts. ArrayLists and Vectors hold an ordered (indexed) set of other objects, but due to the structure used in memory, there's no need to know how many items there are going to be in the collection ...
|4350||Keyboard reader for Java programming newcomers|
I've added a new class of Keyboard Reader for our Java courses [here], for the earlier examples and exercises just after "Hello World". We want to be able to teach people to write a read - calculate - write program early on, but Java inputs require exception handling, and exceptions are objects, and ...
|3045||After Course Resources - do we publish sample answers. Example from Java Exceptions module.|
At the end of each module on our courses, there's an exercise for the delegates. It lets them make use of many of the elements they've learned about to consolidate their knowledge. And it helps me evaluate, as they work through the exercise, how they are progressing; I can "mop up" any major elements ...
|3048||String handling - from first steps to practical examples|
Initial String handling examples on a training course are sometimes a bit mundane - and that's because we have to cover some of the basics like "what is a string" before we start reading them in useful quantities from files, databases, or web resources. But it's important to get those basics understood ...
|2862||Fail Safe Error Handling in Java via Exceptions|
"What could possibly go wrong?" ... The usual answer from a cynic is "anything, and usually at the most inconvenient time, and in the most unexpected way!". So checking for routine errors in your program code is a good start, but it doesn't go far enough; you need to be able to handle errors which are ...
|2622||Handling unusual and error conditions - exceptions|
"I can't answer that question in the way you expect" ... that's something that may be said to you occasionally - you ask someone what suit a playing card is that they're holding and they cannot tell you because it is a joker, or you ask what number is written on a piece of paper when the paper is blank.
|2420||Exceptions in Java - why and how|
Although it's common practise to include a static main test program in a class, it's something that newcomers can have some difficulty following ... so we don't do it too early on the course - we keep classes and programs that use those classes (even if they are just test programs) each in their own ...
|1875||What are exceptions - Python based answer|
How do you check for run time errors in your program? You'll include tests with if statements in almost every program you write, to ensure that user entered data is reasonable / as you would expect ... but you will also need to do more that that. You'll need to check whether a system function has run ...
|1066||Final, Finally and Finalize - three special words in Java|
A final method or variable is one that can't be overridden - you can define a method as final within a class to ensure that any extensions to the class don't replace it.
If you add a finally block onto the end of a try / catch exception handler, you're defining a block of code that will be run if the ...
Examples from our training material
Some modules are available for download
as a sample of our material or under an Open Training Notes License
for free download from [here]
Topics covered in this module
"trying" and "catching".
Defining your own exceptions.
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule
Well House Consultants specialise in training courses in
. We run
throughout the UK (and beyond for longer courses), and
at our training centre in Melksham, Wiltshire, England.
It's surprisingly cost effective to come on our public courses -
even if you live in a different
country or continent to us
We have a technical library of over 700 books on the subjects on which we teach.
These books are available for reference at our training centre.