Win a copy of AWS Security this week in the Cloud/Virtualization 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

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.
 
Come have lunch with me Arthur. Adventure will follow. This tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic