This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes fwd or backward ,don't know which reference?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "fwd or backward ,don Watch "fwd or backward ,don New topic
Author

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

R K Singh
Ranch Hand

Joined: Oct 15, 2001
Posts: 5370

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 ]

"Thanks to Indian media who has over the period of time swiped out intellectual taste from mass Indian population." - Chetan Parekh
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
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


Dave
R K Singh
Ranch Hand

Joined: Oct 15, 2001
Posts: 5370
Hi Dave ..
Thanks a lot ..
now things are clear to me ....
[ January 22, 2002: Message edited by: ravish kumar ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: fwd or backward ,don't know which reference??
 
Similar Threads
Calling Methods with strings??
Statement Doubt
Synchornized Block..
inner class/inheritance
question on NumberFormat class