1. Changes from the Previous Edition

The big change in this edition, of course, is the switch from Java 1 to Java 2. Java 2 did not change the fundamentals of the Java language, but it did introduce many new features. The two that affect this book are the "Swing" graphical user interface library and the framework for generic programming. Java 1 used something called the AWT for GUI programming. Swing has more features and is more sophisticated. I have rewritten all the GUI programming examples to use Swing, and I have extensively rewritten the parts of the book that cover GUI programming. Because Swing is so complex, there are many parts of it that I do not cover, but I do cover enough to write real GUI programs. The other important new feature is a set of "Collection" and "Map" classes that represent generic, reusable data structures. Generic programming has become an important topic, and I have added a new chapter to cover this material.

Java is scheduled to be used as the programming language for the High School Advanced Placement test in computer science starting in the academic year 2003-2004. I've heard from several high school teachers who have used the previous version of this book in their classes, and of several more who are considering using it. Although the previous version already covered most of the AP material, I have made a few changes to improve the coverage. For example, I moved preconditions and postconditions for subroutines from Chapter 9 to Chapter 4, I changed examples that used the Vector class to use the ArrayList class instead, and I briefly introduce the class java.util.Random. There are two versions of the AP test. A course that covered Chapters 1 though 5 and Chapter 8 would include essentially all the material required for the "A" test. Sections 5.5 and 5.6 could be omitted. For the "AB" test, all of Chapter 5 and topics from Chapters 9 through 12 should be added. The AP exam does not require any GUI programming, so Chapters 6 and 7 could be omitted entirely. But a Java course with no graphical programming would be missing out on a lot of the fun.

Here is more detailed chapter-by-chapter description of the changes:

Chapters 1, 2, and 3 are almost unchanged, except for mentions of Swing in Sections 1.6 and 3.7.

Chapter 4: I've added some material to Section 4.6 on preconditions and postconditions for subroutines and included a mention of the javax package in Section 4.5.

Chapter 5: I added some material on java.util.Random and ArrayList and rewrote an example, ShapeDraw, to use ArrayList instead of Vector. I moved material on nested classes from Chapter 7 to Chapter 5. This material plus Section 5.5 was then split into two sections, 5.5 and 5.6. Some of the material from the old 5.5 has moved into Section 5.4. Chapter 6 and 7 were throughly rewritten to use Swing, although the set of concepts that is covered is actually not much changed. Besides the more significant changes, I dropped most of the coverage of threads in favor of timers, since timers are used instead of threads for animation in Swing. I also dropped material on using double-buffering for animation, since double buffering is automatic in Swing. I dropped Section 6.7, which was a short description of event-handling in Java 1.0.

Chapters 8 through 11: Mostly unchanged, although all graphical examples and exercises have been rewritten to use Swing. Also, I added ArrayLists to Section 8.3, and I rewrote the material on networking in Sections 10.4 and 10.5. Some of the material on threads that I dropped from Chapter 7 is now in Section 10.5.

Chapter 12, on generic programming, is all new.

Appendices: I removed the old Appendix 1, which was a description of C++ for Java programmers, and replaced it with a short description of some of the advanced features of Java that are not covered in the text. I rewrote Appendix 2, which is about Java programming environments. And of course, many of the source code files in Appendix 3 have been rewritten to use Java 2.