Team LiB
Previous Section Next Section

Changes in the Fifth Edition

The fifth edition of this book covers Java 5.0. As its incremented version number attests, this new version of Java has a lot of new features. The three most significant new language features are generic types, enumerated types, and annotations, which are covered in a new chapter of their own. Experienced Java programmers who just want to learn about these new features can jump straight to Chapter 4.

Other new language features of Java 5.0 are:

  • The for/in statement for easily iterating through arrays and collections (this statement is sometimes called "foreach").

  • Autoboxing and autounboxing conversions to automatically convert back and forth between primitive values and their corresponding wrapper objects (such as int values and Integer objects) as needed.

  • Varargs methods to define and invoke methods that accept an arbitrary number of arguments.

  • Covariant returns to allow a subclass to override a superclass method and narrow the return type of the method.

  • The import static declaration to import the static members of a type into the namespace.

Although each of these features is new in Java 5.0, none of them is large enough to merit a chapter of its own. Coverage of these features is integrated into Chapter 2.

In addition to these language changes, Java 5.0 also includes changes to the Java platform. Important enhancements include the following:

  • The java.util collections classes have been converted to be generic types, providing support for typesafe collections. This is covered in Chapter 4.

  • The java.util package also includes the new Formatter class. This class enables C-style formatted text output with printf( ) and format( ) methods. Examples are included in Chapter 5. The java.util.Formatter enTRy in the quick reference includes a detailed table of formatting options.

  • The new package java.util.concurrent includes important utilities for threadsafe concurrent programming. Chapter 5 provides examples.

  • java.lang has three new subpackages:

  • java.lang.annotation

  • java.lang.instrument


  • These packages support Java 5.0 annotations and the instrumentation, management, and monitoring of a running Java interpreter. Although their position in the java.lang hierarchy marks these packages as very important, they are not commonly used. Annotation examples are provided in Chapter 4, and a simple instrumentation and management example is found in Chapter 5.

  • New packages have been added to the javax.xml hierarchy. javax.xml.validation supports document validation with schemas. javax.xml.xpath supports the XPath query language. And javax.xml.namespace provides simple support for XML namespaces. Validation and XPath examples are in Chapter 5.

In a mostly futile attempt to make room for this new material, I've had to make some cuts. I've removed coverage of the packages java.beans, java.beans.beancontext,, and org.ietf.jgss from the quick reference. JavaBeans standards have not caught on in core Java APIs and now appear to be relevant only for Swing and related graphical APIs. As such, they are no longer relevant in this book. The package has been deprecated since Java 1.2 and I've taken this opportunity to remove it. And the org.ietf.jgss package is of interest to only a very narrow subset of readers.

Along with removing coverage of java.beans from the quick reference section, I've also cut the chapter on JavaBeans from Part I of this book. The material on JavaBeans naming conventions from that chapter remains useful, however, and has been moved into Chapter 7.

    Team LiB
    Previous Section Next Section