Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

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

 
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
 
author
Sheriff
Posts: 8981
19
  • 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
 
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....
 
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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!