• 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 ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

Head First Java Chapt 4 Mixed Messages" question.  RSS feed

Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

This looks like a puzzle which has stumped a few people in the past here on the forums. I looked at other people questions and the answers but I'm not sure if it helped me. I am trying to work the problem but I'm confused as to how certain pieces of the code works in general. This is page 90 of the Head First Java Book, second edition. I have a few questions to verify how things work so I hope I can communicate my questions correctly. I appreciate any help. Thank You!

Here is the full puzzle code:

Here are the specific lines I'm having problems with. These are lines 10 and 12 from above.


I'm currently working through the problem with pencil and paper and this is what I have this for the first loop.

For line # 11
is " m4a[x].counter" an array reference variable assigned the value of 1 ( counter being 0 at the time) ?
Would I read it as m4a[0].counter = 1?

For line #13
Is the variable "count" now assigned the value 1 plus it calls the maybeNew method?
Does it pass the argument "0" into the "maybeNew" method's parameter and then the "maybeNew" method returns 1?
If I'm correct on any of this would I then read this as count = 1+1?

Posts: 63790
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For that sort of puzzle you will have to get a pencil and paper and go through the execution of the program.

Also search this forum for mixed messages because there is a good chance you will find somebody else has had the same question. Actually, you will probably find this old thread useful.
You get good luck from rubbing the belly of a tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!