Preface 2003 Java
Preface 2003 Java
The purpose of this book is to help you quickly learn the essentials of the Java language. After
its release in 1995, Java was initially used to execute programs from a Web page by means of
applets. However, Java is also a general-purpose, object-oriented programming language. Java
is used for developing applications as diverse as statistical calculations, graphics, and accessing
databases in a multitiered environment. In contrast to other languages, Java has from the start
supplied a large number of libraries. The latest release of Java 2 Standard Edition version 1.4,
or J2SE 1.4, in February 2002 contains over 2000 classes. All this means that Java is huge, and
possible applications of it are very diverse. Furthermore, many Java books tend to be huge,
and though fine as reference material, do not serve the newcomer to Java desiring a concise
introduction. This book focuses on the core language features only, and with the exception of
Swing, does not cover any of the application libraries.
This book is aimed at students and professional programmers who have some knowledge
of programming and are switching to Java. Experience of an objected-oriented or procedural
language such as C++, Smalltalk, C, or Pascal is assumed. The book will be suitable for
students in upper-division undergraduate or graduate Java conversion courses. It is not aimed
at students learning to program. Professional programmers switching to Java will find a
rapid introduction to the core language. This will give them the necessary Java background
for tackling more specialist material such as J2EE. For example, students and enterprise
programmers will find this book provides the Java needed for Gregory Speegle's JDBC book
in this series. This book covers only basic features, and topics such as networking, RMI, and
JavaBeans have not been included.
Recognizing that a programming language is best learned through example, we provide
numerous program examples with line-by-line explanations. To maintain the book's concise-
ness and clarity, the program examples are not production-quality code. For example, exception
handling is omitted from most of the examples, except, of course, in the chapter on exception
xi
xii Preface II
handling. This concise, essentials-only approach is in line with the Practical Guide series over-
all philosophy. The book is based on J2SE 1.4, but anyone using version 1.2 or 1.3 should have
no difficulties since any 1.4 or 1.3 features have been explicitly highlighted in the text.
Chapter 1 dives straight in with a simple example of a Java program. This is to give you
an early feel for the language and show where we are heading. Chapters 2 and 3 cover much of
the basic syntax of Java, including sequencing, branching, and looping, but leaves discussion
of object-oriented topics for later. Those of you with a background in C or C++ will be able to
get quickly through these chapters. Chapters 4 and 5 cover the object-oriented features of the
language. Chapters 6 and 7 cover the core features of exception handling and input/output.
To this point, the chapters should be read in order. The last three chapters may be regarded as
optional by some instructors. Chapter 8 covers the Swing graphical user interface, which is the
one application area covered in the book. Developing GUIs is more fun, and readers coming
from an environment such as C will appreciate what is included for free with Java. Chapter 9
discusses collections. Finally, Chapter 10 covers the more advanced topic of threads. This
chapter uses applets for some of its examples, so you should familiarize yourselves with the
applet material in Chapter 8 before attempting threads.
Source code, exercises, and related material can be found at the book's accompanying
Web site, www.mkp.com/practical/java.
Acknowledgments
First I would like to thank the technical editor of the Practical Guide series, Dr. Jeff Donahoo
of Baylor UniversiW, for his advice and numerous suggestions at all stages of the book's
development. This is really appreciated. I would like to thank the reviewers. These include Carl
Burnham; John Raley, Moonlight Systems; Lynn R. Ziegler, Saint John's University; An Lam,
3PARdata and U.C. Santa Cruz; Bill Jackson, Ensemble Studios; Dr. Lawrence (Pete) Petersen,
Texas A&M University; Jonathan L. Brisbin; Christopher Marshall, JP Morgan; William Cox, Cox
Consulting; Simon P. Chappell; Ryan Witcher, Modulant Solutions. All the reviewers provided
considerable feedback and this has influenced the final version of the book. I would also like
to thank the staff at Morgan Kaufmann, especially Karyn Johnson for her professionalism and,
for giving me the opportunity to publish the book, Edward Wade, Cheri Palmer, and the rest
of the production team.