There are many books on Java that teach you how to use the language, but few books that teach you why the language works in the way that it does.
Many books help you learn the mechanics of Java programming; few books teach you the deeper issues that lie behind the programming syntax. The goal of this book is to give the reader a fuller, more complete understanding of the philosophy behind Java, not just the mechanics of the language.
Throughout the book these principles and practices are illustrated with exten-sive examples from the Java standard library. Here you can learn, for example, the many design patterns that are found in the AWT, the multitude of purposes for which inheritance is used in the standard classes, and why there are 22 dif-ferent types of input/output file streams. Here you can discover why the lack of an ordered container class in the standard library is not a simple omission, but is instead a re ection of a fundamental and deep property of the Java language. In short, this book should not be considered a reference manual for the Java language, but rather a tool for understanding the Java philosophy.
Structure of the Book The book is structured in five major sections:
Part 1 is a general, language-independent introduction to the ideas that lie at the heart of the Java world. The first major object-oriented concepts, those of classes, encapsulation, behavior, and responsibilities, will be introduced in this part and reinforced in Part 2. Here the student will be introduced to the idea that the solution to a problem can be structured as interactions among a community of agents. The second chapter of Part 1 presents a brief history of the development of Java, and can be omitted at the instructor's discretion. However, Chapter 3, on design, should in no way be avoided. In fact, I strongly encourage students to conduct at least one, if not several, design exercises using CRC cards, similar to the one presented here, even before they start to learn aspects of the Java programming language.
Part 2 introduces Java through several graduated example programs (paradigms, in the original sense of the word). These examples lead the reader through successively more of the Java language, introducing new features as they are required for specific applications. This is not a systematic introduction to all of the Java language, but rather provides examples designed to motivate the need for mechanisms discussed in other parts of the text.
Part 3 discusses inheritance, the next major object-oriented concept that the student must master after learning about classes and objects. Inheritance is a technique that is superficially obvious, but that possesses many subtle aspects that can trap the unwary programmer. The introduction of inheritance into a programming language has an impact on almost every other aspect of the lan-guage. For this reason, students familiar with conventional non-object-oriented languages should pay careful attention to this part of the book.
Part 4 discusses polymorphism, which is often an even subtler concept for the student to understand than inheritance. Polymorphism is the mechanism through which much of the power and applicability of object-oriented tech-niques is manifest. Polymorphism is found in Java in many ways, as shown by the extensive examples studied in this part of the book.
Part 5 discusses features of the Java world that are important for the student to understand, but not particularly notable for their object-oriented features. These items are separated from the remainder of the text so that they do not interrupt the ow of the narrative developed earlier in the book. However, the features discussed are not as difficult as their late placement in the book might indicate. At the instructor's discretion these features can be omitted altogether, or introduced in parallel with earlier material.
Obtaining the Source Source code for the case studies presented in the book can be accessed via the mechanism of anonymous ftp from the machine ftp.cs.orst.edu, in the directory /pub/budd/java. This directory is also used to maintain a number of other items, such as an errata list. edu/ ~budd/. Requests for further information can be forwarded to the electronic mail address budd@cs.orst.edu, or to Professor Timothy A. Budd, Department of Computer Science, Oregon State University, Corvallis, Oregon, 97331.
Acknowledgments Invaluable advice was provided by the reviewers who examined an early draft of the book. These included Richard Anderson, University of Washington; Richard Carver, George Mason University; Deborah Frincke, University of Idaho; Matt Greenwood, Bell Laboratories; David Riley, University of WisconsinLa Crosse; J. Richard Rinewalt, Texas Christian University.
I would like to thank my editors at Addison-Wesley, Susan Hartman and Deborah Lafferty, who patiently and quietly suffered through countless delays and postponements. It is my sincere hope that they, as well as the reader, will find the result to have been worth the wait.