• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

fwd or backward ,don't know which reference??

 
Ranch Hand
Posts: 5399
1
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I am not able to get why at LINE01 member variable of class B is not being assigned null
?
2. is it possible for object obj1 to be accesible from object obj2 and object obj2 to be accesible form obj1 ??
TIA
[ January 22, 2002: Message edited by: ravish kumar ]
[ January 22, 2002: Message edited by: ravish kumar ]
 
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ravish
At LINE 01 the member variable is being assigned null. Actually you dont get a reference to the object that is created so you cant even test it anyway.
You're creating a B object in the creation expression for a1 so you are just passing a value of null to the constructor - you have no reference to the B object created except through the the A1 objects bb member. But you're still creating a valid B object even though one of its members has a value of null. Look at this code here with comments exlaining what is happening (I commented out the toString methods so you can see that they are different objects being created):

hope that helps
 
R K Singh
Ranch Hand
Posts: 5399
1
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dave ..
Thanks a lot ..
now things are clear to me ....
[ January 22, 2002: Message edited by: ravish kumar ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic