This method demonstrates calling a method that might throw
an exception, and catching the resulting exception.
Object o = null;
for (int i=0; i<5; i++) {
try {
o = makeObj(i);
} catch (IllegalArgumentException e) {
System.err.println("Error: (" + e.getMessage() + ").");
return; // cut off println below if makeObj failed.
}
System.out.println(o); // process the created object in some way
}