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/instatement 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
intvalues andIntegerobjects) 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 staticdeclaration to import thestaticmembers 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.utilcollections classes have been converted to be generic types, providing support for typesafe collections. ...