Here's an example of what I mean.
If I have a binary tree insert method that accepts a node, and I pass it parent.child (which is uninstantiated) what exactly is being passed?
Since Java is pass by value it must be passing a copy of the reference but without any object to point to what will happen? Does that mean I'm passing an empty reference that has no relevance to the parent node?
Unfortunately I don't have any code since this was actually a question that was passed onto me and I couldn't quite put it together. My solution was to pass a parent node which is already instantiated and then instantiate parent.child
Here's an example. Consider the type
So, assuming
nullis a special value, say 0x0000, somewhere in memory (YMMV), there's aIn other words, there's a
Nodeobject, with achildfield storingnullas its value. Additionally, there's a variableparentstoring the value (an address of sorts) of theNodeobject.When you do
You're dereferencing
parent, thereby getting its address,0x1000, figuring out at which offset itschildfield is,0x1004, and getting its value,0x0000. You then copy that value on the stack. The method invocation will pop that value from the stack and bind it to this newnodevariable. So now you haveTo answer your question
You're passing a
nullreference. There will be no way to retrieve whateverparentwas referencing from the bound parameter.