• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

shadowing an object

 
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
from P-218 kathy sierra
shadowing a object.........


The preceding code prints out this:
f.myBar.barNum is 28
myBar.barNum in changeIt is 99
myBar.barNum in changeIt is now 420
f.myBar.barNum after changeIt is 99


can anybody tell me how the output comes i am not able to understand this.....................
 
Ranch Hand
Posts: 446
1
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
take following points into consideration
1. assigning one variable to another variable means that we are copying the bits present in one variable into another variable

we will first see how the objects are their reference variables are

the reference variables hold the bits which represent the memory of the object at which it is stored (unlike primitives where direct value (those are also bits )are copied )
so even when we assign one reference variable to some another reference variable then the bits that represent the memory at which object resides are copied (hence the object is not copied and the object is the same and both the reference variables refer to the same object now )

read the comments in the program now
start the flow from main method


was a little complicated
I hope I have explained well but if you still don't have understood
feel free to ask , I will write full explanation then
but first go through the explanation in the book once again
happy learning
 
This will take every ounce of my mental strength! All for a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic