This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Some confused points in pass-by-value topic, chapter 4 (Java OCA 8 Programmer I Study Guide, Sybex)

 
Mushfiq Mammadov
Ranch Hand
Posts: 187
25
Java jQuery Netbeans IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

“Pass-by-value” is one of the most confusing topic for me until I read this topic from OCA book. This topic is explained very well, I could understand some points which was unclear for me.
I have some confused notes about this topic and I would like to share it.

1. On page 188, the latest row
Don’t we pass num variable instead of 5 or I think wrong? As this

2. On page 191, line #5 of example
The note which is written after comment in line 5 ( // 1 ) is confused me. I understand such comment show output which the same line return. Line 5 returns 2 but we know that this code doesn’t change the value of number. Maybe authors write value of number variable in it so they want to show that value of number variable isn’t change in that line, so it is explained the last paragraph of section.

3. On page 191, the last paragraph of section, fifth sentence:
Maybe numbers should be number.

Sorry for my English, maybe I don’t say my opinion correctly.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's another excellent article about the pass-by-value concept.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mushfiq Mammadov wrote:1. On page 188, the latest row

The actual code in the book is correct, but newNumber(5); isn't an example of pass-by-value. Should indeed beto have a true illustrative pass-by-value example

Mushfiq Mammadov wrote:2. On page 191, line #5 of example

I agree with you on this one: the comment behind the statement could indeed be confusing, certainly for the method invocations because you have the value of the parameter and you have the return value (which might be ignored). But there is just one number. If you have a look at the code (and/or read the explanation in the section), it's obviously the value of the variable used in the statement. Once you know this, these comments are not confusing anymore, but at a 1st glance it probably could be. And because the code is well explained in the section directly below the code, these line comments could even be dropped. Or for more clarity could be a little bit extended toor even more verboseBoth indicate the value of the variable before and after this statement. Just a suggestion, don't know if it really improves the understanding of the comments in the code snippet

Mushfiq Mammadov wrote:3. On page 191, the last paragraph of section, fifth sentence:

Not maybe, but definitely

Mushfiq Mammadov wrote:Sorry for my English, maybe I don’t say my opinion correctly.

I think I understood everything correctly after a 1st read, so no problem here

Hope it helps!
Kind regards,
Roel
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mushfiq Mammadov wrote:Don’t we pass num variable instead of 5 or I think wrong?


Mushfiq Mammadov wrote:3. On page 191, the last paragraph of section, fifth sentence:
Maybe numbers should be number.


Added these two the errata. I've noted your other comments in a private list I'm keeping of "things that could be clearer, but aren't wrong." Thanks!
 
Bram Vonk
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:...

Mushfiq Mammadov wrote:3. On page 191, the last paragraph of section, fifth sentence:
Maybe numbers should be number.


Added these two the errata.

An erratum to the errata: the errata says the 3rd paragraph, but it is the 4th.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bram Vonk wrote:An erratum to the errata: the errata says the 3rd paragraph, but it is the 4th.

Noted. Thank you. And welcome to CodeRanch!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic