File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Head First Java 2nd Ed. Correction?... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Head First Java 2nd Ed. Correction?..." Watch "Head First Java 2nd Ed. Correction?..." New topic

Head First Java 2nd Ed. Correction?...

Glen Kidston

Joined: Feb 26, 2005
Posts: 9
Greetings Big Moosers.
I just picked up
Head First Java (2nd Edition - Covers Java 5.0)
. For the
Be the compiler
exercises A and B on page 63, the corresponding solutions (right half of page 68) indicate that these classes need to be changed to compile. This isnt what I thought when I did the exercises and was surprised to see corrections during subsequent review of the answers. Being a good sport, I typed these two exercises (three classes) into two *.java files, named
. I then compiled them without a hitch. They dont run, but they do compile. And I understand why they get NullPointerException and ArrayIndexBoundsException respectively. Should the name/purpose of this exercise be changed from
Be the compiler
Be the JVM
and make the point of the exercise be to play JVM and determine how to change each of these files so that they will both compile and run without error? Thank you for reading and your time.
Bert Bates

Joined: Oct 14, 2002
Posts: 8898
Hey Glen,


You are correct! We should have called this exercise... "Be the JVM"... although that might have been a big clue... hmmm... we'll come up with some sort of creative solution.

Anyway, thanks for a good catch! It's amazing to us that you're the first person to bring this up after a year and a half



Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
"Be the JDK"?

"I'm not back." - Bill Harding, Twister
Glen Kidston

Joined: Feb 26, 2005
Posts: 9
Hmmmm... Not bad at all. I was thinking personally that I should maybe stick to reviewing and leave the creative stuff to the authors, but maybe that's a cop out. Plus I just had gum surgery, so I'm not feeling very creative. Keep up the good work everyone! Ouch and bye....
Saravanan Jothimani

Joined: Feb 25, 2005
Posts: 26
I Cant understand what you are trying to say.


Glen Kidston

Joined: Feb 26, 2005
Posts: 9
My confusion was that the goal of these exercises was to "Be the compiler".
The thing is, the compiler does not have a problem with the coding errors in these exercises. I verified this by typing the Java programming language statements from the exercises into files called "" and "". I then ran these two new files through the Java compiler, and it turns out that they compile (into *.class files) without any errors. The errors happen later, when you try to actually run the resulting classes (via the Java Virtual Machine). Hence the "Be the JVM" "Be the JDK" suggestions. I like the examples and their presentation, and I do hope I am not confusing matters, but I found it confusing that these programs do compile but do not run.
I agree. Here's the link:
subject: Head First Java 2nd Ed. Correction?...
It's not a secret anymore!