Java Reference
In-Depth Information
Chapter 10 describes arrays. Array accesses include bounds checking. Arrays are dynamic-
ally created objects and may be assigned to variables of type Object . The language supports
arrays of arrays, rather than multidimensional arrays.
Chapter 11 describes exceptions, which are nonresuming and fully integrated with the
language semantics and concurrency mechanisms. There are three kinds of exceptions:
checked exceptions, run-time exceptions, and errors. The compiler ensures that checked
exceptions are properly handled by requiring that a method or constructor can result in a
checked exception only if the method or constructor declares it. This provides compile-
time checking that exception handlers exist, and aids programming in the large. Most user-
defined exceptions should be checked exceptions. Invalid operations in the program detec-
ted by the Java Virtual Machine result in run-time exceptions, such as NullPointerException .
Errors result from failures detected by the Java Virtual Machine, such as OutOfMemoryError .
Most simple programs do not try to handle errors.
Chapter 12 describes activities that occur during execution of a program. A program is nor-
mally stored as binary files representing compiled classes and interfaces. These binary files
can be loaded into a Java Virtual Machine, linked to other classes and interfaces, and ini-
tialized.
After initialization, class methods and class variables may be used. Some classes may be
instantiated to create new objects of the class type. Objects that are class instances also
contain an instance of each superclass of the class, and object creation involves recursive
creation of these superclass instances.
When an object is no longer referenced, it may be reclaimed by the garbage collector. If an
object declares a finalizer, the finalizer is executed before the object is reclaimed to give
the object a last chance to clean up resources that would not otherwise be released. When a
class is no longer needed, it may be unloaded.
Chapter 13 describes binary compatibility, specifying the impact of changes to types on
other types that use the changed types but have not been recompiled. These considerations
are of interest to developers of types that are to be widely distributed, in a continuing series
of versions, often through the Internet. Good program development environments automat-
ically recompile dependent code whenever a type is changed, so most programmers need
not be concerned about these details.
Chapter 14 describes blocks and statements, which are based on C and C++. The language
has no goto statement, but includes labeled break and continue statements. Unlike C, the Java
programming language requires boolean (or Boolean ) expressions in control-flow statements,
and does not convert types to boolean implicitly (except through unboxing), in the hope of
Search WWH ::




Custom Search