The reference set to null is the local copy of the form2 reference. As the reference is passed by value, meaning making an exact copy and passing the copy, the original remains untouched The value passed here can be seen as a memory address (which is not exactly the case vith VMs but it is a helpful and adequate metaphor) In the test method, you set a variable holding a copy of this address to null This has no further consequences whatsoever The case is very different if you use the address stored in the variable to access and change the actual Object the address refers to. You are changing the real thing here, so all changes remain after your local variable runs out of scope To take one more step back : You can see the variable as a slip of paper with an address of a friend (your object).
If you burn the paper (setting the variable to null), your friend is not affected. If you use the paper to visit the address and give your friend a present or slap him in the face (calling a method on the object behind the variable), he is definitely affected and you have to live with the consequences.
The reference set to null is the local copy of the form2 reference. As the reference is passed by value, meaning making an exact copy and passing the copy, the original remains untouched. The value passed here can be seen as a memory address (which is not exactly the case vith VMs but it is a helpful and adequate metaphor).
In the test method, you set a variable holding a copy of this address to null. This has no further consequences whatsoever. The case is very different if you use the address stored in the variable to access and change the actual Object the address refers to.
You are changing the real thing here, so all changes remain after your local variable runs out of scope. To take one more step back : You can see the variable as a slip of paper with an address of a friend (your object). If you burn the paper (setting the variable to null), your friend is not affected.
If you use the paper to visit the address and give your friend a present or slap him in the face (calling a method on the object behind the variable), he is definitely affected and you have to live with the consequences.
Agreed, so why does setting f. Text = "Form2"; reflect in the main function – Rauld May 25 at 11:58 @Rauld - updated the answer with further explanation, hope it makes the matter clearer – kostja May 25 at 12:40 thank you, makes sense now – Rauld May 26 at 6:55.
(I'm assuming this is Java. ) Method parameters are always passed by value. That means their contents are always copied to a new variable.In this case the contents of the variable f, which contains a reference to an object, are copied to a new variable.
When that new variable's contents are replaced with null, the contents of the original variable are unaffected -- they still point to the original object.
Agreed, so why does setting f. Text = "Form2"; reflect in the main function. – Rauld May 25 at 11:57.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.