This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General 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
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Can someone explain!!!

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

Edited By Corey McGlone: Added CODE Tags
[ July 24, 2003: Message edited by: Corey McGlone ]
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

First off we I'm assuming you understand the order of the "System.out"s, if not just let us know.
So now we have:
1)at line 23 we create a new ValHold object vh which has vh.i=10
at line 24 we use our new ValHold object vh created at line 23 and set v=vh
so now v.i=10
2)in method another() i was passed in with value of 99
but we immediately set i=0 at line 21
3)at line 16 we pass v into method another() and v.i=30 at this point
when we pass objects as parameters we are actually passing a copy of the reference
so at line 22 when v.i=20 that will also apply to the v object in the method amethod()
at line 24 we set method anonther()'s v to point to a diferent object, this does does not affect method amethod()'s v though
so at line 17 v.i=20
Hope that makes sense.
 
Salman Riaz
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cheers paul!!
 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can also check out this.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!