This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Array Reference

 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to all ranchers,

I'm just confused, I found this question from the Java Rule Round-Up Exam.

(#8) When you pass a reference to an array as an argument to a method call, you pass a NEW reference to the original array.

I answered false, because I think that it's not a NEW reference being passed but only a COPY of the reference. But it says its TRUE. But when I look at the explanation, it says "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." And I agree with the explanation, however, why is it TRUE?

I'm just really confused. Can anybody point out what I am missing out here?

Thanks!
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A copy of the reference is indeed a NEW reference, the object that it refers to is the same as the original one, but the reference itself is indeed new. The point of that question is "Copy of the reference is passed", not the reference itself, that's what it means by "New". Hope it helps.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic