
11.1 Simple Exception Handling 737
or try to access the 11th element in a 10-element array. Java is a robust lan-
guage and does not allow these “illegal” operations to occur unnoticed.
These illegal operations generate exceptions. Some exceptions are gener-
ated by the Java Virtual Machine, while others are generated by construc-
tors or other methods. For example, a method might generate an exception
when it detects an attempted illegal operation or an illegal parameter.
By default, when an exception is generated in an application that does not
have a graphical user interface, the program will terminate. In many cases,
however, we can attempt to reco ...