Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Sponsored Links

Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs

Book on the Java API is a must-have for Java programmers

<em>The Java Application Programming Interface Volumes I & II</em> by James Gosling and Frank Yellin

  • Print
  • Feedback
So you already have a bookshelf full of the classics. Well, make room next to K&R, Knuth, and the dragon book because this set is absolutely essential for Java programmers. This book belongs in that rarefied company because it has exactly the information a Java programmer needs -- arranged so that it is a joy to use. And it's written by the folk who know the language best.

Gosling and Yellin's definition of the Java API is nothing if not thorough. The first volume covers the core packages: java.lang, java.io, java.util and java.net. The second volume defines the windows toolkit and applet packages: java.awt, java.awt.image, java.awt.peer and java.applet. Each class and interface in these packages is clearly and minutely defined with text descriptions of each public class, field, constructor, and method. What makes this reference so good is that it's not just a nicely formatted printout of class declarations. Each class, method, field, and interface is described in a text note that tells you exactly what you need to know quickly, so you can get on with your coding. The text descriptions truly provide useful information. For example, in the definition of a constructor for the public class ThreadGroup, Gosling and Yellin tell us:

public ThreadGroup(ThreadGroup parent, String name)


Creates a new thread group. the parent of this new group is the specified thread group.
The checkAccess method of the parent group is called with no arguments; this may result in a security exception.

Parameters: parent: the parent thread group
name: the name of the new thread group

Throws: NullPointerException
if the thread group argument is null.
Throws: SecurityException
if the current thread cannot create a thread in the specified thread group.



This kind of information can be invaluable to the coder sitting there -- one hand on the keyboard and the other holding the reference. Taking this one step further, the authors describe one of ThreadGroup's enumerate methods:



enumerate
public int enumerate(Thread list[]) 


Copies into the specified array every active thread in this thread group and its subgroups.

An application should use the activeCount method to get an estimate of how big the array should be. If the array is too short to hold all the threads, the extra threads are silently ignored.



That short note will save Java programmers a lot of time. As Gosling said in his keynote at JavaOne, he's made just about every mistake there is to be made, coding-wise. And he doesn't think he has the time to make those mistakes again. Fortunately for us, he doesn't think we have the time either.

In addition to the superb comments and warnings about common errors, the book is arranged to be very usable. In the back, there is a 65-page index that has just the right level of granularity. This is the make-or-break feature of many reference books, as no one actually goes through a reference from page one forward. You pick it up because you're looking for something, and this index will get you where you need to go with minimal sidetracks.

  • Print
  • Feedback

Resources