Flylib.com

Books Software

 
 
 

Dedication


Dedication

This book is dedicated to all
who teach peace and resist violence.


Copyright 2005, 2002, 1999, 1997, 1996 O'Reilly Media, Inc. All rights reserved.

Printed in the United States of America.

Published by O'Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.

O'Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://safari.oreilly.com). For more information, contact our corporate/institutional sales department: (800) 998-9938 or corporate@oreilly.com.

Nutshell Handbook, the Nutshell Handbook logo, and the O'Reilly logo are registered trademarks of O'Reilly Media, Inc. Java in a Nutshell, the image of the Javan tiger, and related trade dress are trademarks of O'Reilly Media, Inc.

Java and all Java-based trademarks and logos are trademarks or registered trademarks of Sun Microsystems, Inc., in the United States and other countries . O'Reilly Media is independent of Sun Microsystems.

Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O'Reilly Media, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps.

While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein.


Preface

This book is a desktop Java quick reference, designed to sit faithfully by your keyboard while you program. Part I of the book is a fast-paced, "no-fluff" introduction to the Java programming language and the core APIs of the Java platform. Part II is a quick reference section that succinctly details most classes and interfaces of those core APIs. The book covers Java 1.0, 1.1, 1.2, 1.3, 1.4, and 5.0.


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

  • java.lang.management

  • 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 , java.security.acl , 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 java.security.acl 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.