This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Hands On Software Engineering with Python and have Brian Allbey on-line!
See this thread for details.
Win a copy of Hands On Software Engineering with Python this week in the Jython/Python 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

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

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

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.

and



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?


 
Marshal
Posts: 62163
193
  • 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.
 
"I know this defies the law of gravity... but I never studied law." -B. Bunny Defiant tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!