Earlier this year, I was asked by an editor at Pearson to write this phrasebook focused on Java. It is one of several in their Phrasebook series. Christian Wenz wrote the first one in the series, the PHP Phrasebook. The concept for the phrasebook series comes from the foreign language phrasebooks. Foreign language phrasebooks contain a list of common phrases that you might want to say in the foreign language. These books are very useful for visitors who do not know the local language. The concept of technical phrasebooks is similar. They show the reader how to accomplish common tasks using the technology which is the subject of the book.
The goal of this phrasebook is to provide you with a guide book of commonly used Java programming phrases. This book should be useful to both the seasoned Java programmer and the programmer who is new to Java. Although the book can be read cover-to-cover to get a good overview of the Java language, the book is best used as an on-hand reference when the programmer wants to know how to accomplish a common task in the Java language. You may also wish to explore the book to discover some Java features and techniques that you may not have been aware of before.
The book is not a Java language tutorial or introduction, nor is it a complete reference to the Java language. There are many more classes and APIs than what you will find covered in this book. There are already many excellent learning Java style books and Java reference books covering pretty much every technology you can think of. If your goal is to get a deeper understanding of a specific technology, this is not the book you are looking for.
Most of the phrases and sample code shown in this book do not contain error handling code. Many of the phrases may throw exceptions that you will have to handle in any real applications that you write. The error and exception handling code is not shown in this book so that the reader can focus on the purpose of the phrase or sample code without being distracted by a lot of error handling code. When you include all of the standard exception handling in a code sample, the phrase can quickly become something much more than a short concise phrase, and yet showing all of the exception handling code will not have helped you to understand the specific phrase any better. Not showing the error handling code allows the phrases to be kept short and concise. The JavaDoc for the Java JDK is an excellent source for looking up which exceptions can be thrown by any method contained in the Java classes that you will come across in this book.
The phrases contained in this book should be OS independent. The Java platform's motto of write-once-run-anywhere should apply to all of the phrases and sample code contained in this book. The phrases were tested under JDK 1.5, also referred to as Java 5.0. Most of the phrases will work well under earlier versions of the JDK as well, except where noted.
While writing this book, I have tried to come up with what I considered to be the most useful phrases while maintaining the concise format of the Phrasebook series. I am certain that at some point you will be looking for a certain phrase that you will not find in this book. If you feel that a phrase should be included in this book, I'd like to hear from you. Also, if you feel that there are phrases contained in this book which are less than useful, please tell me that as well. As a writer, I always enjoy feedback from my readers. Perhaps at some point in the future you will see a second edition of this book that takes your feedback into account.