• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Rule Round-up #8

 
Ajit Deshpande
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The wording of Question #8 is not very clear. It says:
When you pass a reference to an array as an argument to a method call, you pass a new reference to the original array.(True or False)
You actually pass a copy of the reference and not a new reference.
 
paul wheaton
Trailboss
Pie
Posts: 21390
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
#8: TRUE or FALSE: When you pass a reference to an array as an argument to a method call, you pass a new reference to the original array.
The answer is: TRUE - An array is an object, and Java always passes a copy of the reference to the original object. Both references now point to the same array object.
Hmmm, changing this to "you pass a copy of the reference..." might be a good idea.
Anybody else?
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, it is clearer the second way. I think the first is OK, but the word "new" has mixed connotations which it's best to avoid.
 
paul wheaton
Trailboss
Pie
Posts: 21390
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've made the change.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic