This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Glen Kidston
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
BooksTestDrive.java
and
Hobbits.java
. 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
to
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.
Sincerely,
-Glen
 
Bert Bates
author
Sheriff
Posts: 8898
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Glen,

:roll:

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

Thanks,

Bert
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Be the JDK"?
 
Glen Kidston
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I Cant understand what you are trying to say.

Regards

Saravanan
 
Glen Kidston
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 "BooksTestDrive.java" and "Hobbits.java". 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic