Doug is a programmer at a company making data loggers. He can be contacted at doug_nickerson@onsetcomp.com.
438 pp., $14.95
354 pp., $34.95
414 pp., $24.99
There are many Java books available this season, most of which mix salesmanship with technical writing. Many authors cannot present Java feature by feature without explaining why the design or implementation of a particular feature is the best, perhaps, in history.
One of the books I'll examine, Just Java, occasionally displays this weakness; Java Programming Language Handbook, much less so; and Java in a Nutshell, not at all.
The books, of course, are dissimilar. Java in a Nutshell is an example-laden, quick reference that assumes a familiarity with programming, ideally in C. Just Java and Java Programming Language Handbook, on the other hand, are tutorials that might be better suited for beginning to intermediate programmers.
David Flanagan's Java in a Nutshell has quality stamped on its cover and embedded in its acid-free paper. O'Reilly has a reputation for books with terse, accessible writing--and this book is no exception.
The book has 33 sections, a glossary, and an index. The first three sections introduce Java. The next six sections contain examples of applets, GUIs, I/O, networking, advanced graphics, and threads. The examples get gradually harder within the sections, but not necessarily from section to section. That's it, except for the "Java Language Reference," "API Reference," and "API Cross-Reference," and months of further study. All in all, I like the tone, topics, examples, level of detail, and the layout.
"How Java Differs From C" exhibits the tone of the book. Flanagan minces no words as he pursues packages, CLASSPATH, imports, types, objects, garbage collection, and exceptions from the point of view of a C programmer. Java is more like C than C++, he says.
The FileViewer example views a text file with the file name as a command-line parameter. It worked the first time. I converted FileViewer to an applet by adding an init() method and deleting main(). I converted the command-line parameter to a <PARAM> tag in an HTML file, and added the code to read in the file name as a String. This worked well with the AppletViewer under Windows 95, but the JDK on a Power Mac 6100 (Java Version 1.0b2) quit with a NullPointerException on the line loading the file name.
The GUI section introduces class InfoDialog, then adds a user response with Yes/No/Cancel buttons. This demonstrates use of a widget and response to events via an action() and answer() method. All the high-quality examples can be downloaded from http://www.ora.com/catalog/javanut.
Java in a Nutshell is well laid out. The examples contain many cross-references, and the tabs on the page ends make locating sections easy. This is a detailed volume, with more in it than I can describe here--check out the section on Unicode.
There was a glitch in the book in Section 3, page 68, that incorrectly implied that you can overload methods by merely defining a method with a different return type (same name and parameters). After I read about this on the errata sheet on the web page, I looked for it in the other books. (Just Java makes the correct point very clearly, for example.)
I'm sure this book will meet the needs of programmers everywhere who want to get up to speed with Java.
Just Java is one of a series of books from SunSoft Press. (There are three others as of this writing.) Its author, Peter van der Linden, works at Sun and is the author of a previous book on C: Effective C Programming. Whereas Java in a Nutshell is a reference, this book is more representative of the type of tutorial programming books that often turn up on bookstore shelves.
The first chapter provides a history of the web and hypertext. Many programmers will be familiar with some of this material. (The story of Java's genesis within Sun takes on more legendary proportions with every retelling.) "The Story of O" is an introduction to object orientation containing good, common-sense explanations of inheritance and polymorphism, and some comparisons to C syntax that I've never heard before.
After some chapters delving into various language topics, the run-time libraries are summarized: I/O, networking, and the AWT (Abstract Window Toolkit). Each chapter has a "Light Relief" section at its end. The humor was a little heavy handed at times.
Although I enjoyed many things about this book, its organizational problems troubled me. The order of material was good overall, but the flow and relationship of topics within the sections was sometimes confusing.
Chapter 7 is an example. It presents an overview of features of the I/O package. This is a Herculean task to be sure, but van der Linden switches between function summaries and more detailed explanations so quickly it is dizzying. A gradual development of I/O examples would have been more helpful.
Understanding the relationship among components, containers, windows, and frames is crucial to understanding the AWT. Peer objects link the GUI features of the AWT with the widgets available on the local platform. These topics can use some exposition, and here they get it. UI controls, windows, buttons, and text fields are presented by a screen shot, code to create each widget, and a short description. A GUI library lends itself well to this method of presentation.
The CD included is approximately the same as the disks for every book in this series. It includes the JDK 1.0, example code, WinZip, WinEdit, and Symantec's Cafe Lite. Windows 95, NT, Solaris 2, and Macintosh are all supported. Many of the examples are short segments from the text. Examples from Java by Example--notably some applets--are also included.
Overall, I enjoyed and learned from Just Java. The author is congenial, has wide experience (not surprisingly, he knows his UNIX), and his enthusiasm for Java is catching. The book contains much good material; too bad the reader has to exert so much effort to get at it.
Java Programming Language Handbook is a tutorial with bite. David Friedel and Anthony Potts have provided a 414-page book that covers the main features of Java in a relaxed style. Although the authors have the space to ramble in this type of book, here they succeed in explaining without wasting words.
The TickerTape applet is used as a vehicle to introduce applet life cycles, types, imports, method overrides, double buffers, and threads. This worked better than it would have had they introduced these concepts in isolation.
This book has a good discussion of upcasts and downcasts. Downcasts represent a widening of the fields in an object, while upcasts are a narrowing. Therefore, down-casts will cause a run-time error, even though they're accepted by the compiler. In contrast, C++ compilers sometimes have a type-safe downcast macro that is useful in such a case.
InputStream and OutputStream are abstract classes from which byte-stream I/O classes are derived; many I/O operations can throw exceptions and thus need to be surrounded with try/catch clauses. Various subclasses provide buffered I/O, (BufferedInputStream, BufferedOutputStream) and file I/O (FileInputStream, FileOutputStream). Key methods in each class are listed, then example code demonstrates their usage.
The frequent use of tables to organize important methods, package names, keywords, types, and sizes worked well for me. There is a language-reference card in the back.
The book does not come with a disk, but the examples are nicely integrated into the text, and you can also get them at http://www.coriolis.com/java.
An appendix gives details about linking Java with SQL, of all things. It describes version 0.5 of the JDBC (Java Database Connectivity) API: a nice touch at the end of a well-written, useful book.
Just Java might be most suitable for beginners, Java Programming Language Handbook for anyone who likes a good tutorial approach, and Java in a Nutshell for intermediate programmers who need a book they can use now as well as in the future. If Java in a Nutshell seems to overshadow the other two books, it's because it casts a very long shadow.