Java Reference
In-Depth Information
support, improved printing support for some graphics components, and the ability to
query for the mouse location on the desktop.
New concurrency features - Chapter 8 discusses Java's multithreading support, which
has been present since version 1.0. Release 5.0 adds new capabilities that greatly enhance
the multithreading features of Java. Some of these additions depend upon the generics
concept (see next item), so we wait until Chapter 10 to introduce these important new
capabilities.
Generics -InChapter 10 we introduce the new generics feature, a large and important
subject that we do not have space to cover in detail in this topic. Java is already a very
type-safe language, which simply means that every variable has a specific type and that
only compatible types can be assigned to each other. However, the use of generics brings
an even greater amount of type safety to the Java language. Java includes a number of
“object containers,” such as the ArrayList class, that can contain “objects” of many
different types. When retrieving an object from one of these containers, it must be
retrieved as a very basic type and then converted back to the original type. If, however,
an incorrect type is added to the container, then an error occurs at runtime during the
conversion attempt. The use of generics makes it possible for the object containers to
require that only certain types can be placed into them, else a compile time error occurs.
Since mistakes are found at compile time, runtime safety and correctness is improved. In
addition, since the specialized containers only contain items of the desired type, retrieval
of items from the containers is easier since no explicit conversion to the desired type is
necessary.
Yo u are not required to use the generics approach but see the note at the end of
Section 10.7 about using the 5.0 compiler with code that uses the older containers.
Enumerated types - Chapter 10 presents a feature of C/C
that many programmers
have missed in Java. Version 5.0 adds an enumerated type using the enum keyword.
The new Java enumerated type includes all the features of C/C
++
++ enum and more,
including type safety.
New StringBuilder class -Wediscuss this new class in Chapter 10, along with
the older StringBuffer class. Both are used in the building, concatenating, and
appending of string types, but the new class has improved performance.
Changes to ease RMI development - Chapter 18 explains the Remote Method Invoca-
tion (RMI) techniques, including a simple but important change in J2SE 5.0 that makes
RMI development simpler.
We do not go into great depth in this topic on these changes. To do so would
require an entire topic just for those changes. In fact, at least one topic devoted
entirely to Release 5.0 is available at the time of this writing [9]. There is also much
documentation available online at http://java.sun.com , though reading
that documentation is sometimes difficult. By the time this topic is in your hands,
there are sure to be more topics devoted to Java Version 5.0 that explain all the
new features in more detail than we can provide here. We expect one of those
Search WWH ::




Custom Search