// class test
Now coming to your question, if two variables are pointing to the same thing and one of them then starts pointing to something else, should it change what the other variable was pointing to also?
Here is a post that might interest you. That should answer your first question.
Ok, so before we take your second question, let's just get a confirmation from you that you understand the answer of the first one.
[ Edit : Ninja'd ]
* Notes: Java is pass by value always. Pass-by-value means that when you call a method, a copy of the value of each actual parameter is passed to the method. You can change that
* copy inside the method, but this will have no effect on the calling method.
* If the variable you are passing in is of reference type and you change the properties of the referred
* to object without pointing the reference to a new object then your changes will be visible in the calling method. The reference was still passed by value.
Time is the best teacher, but unfortunately, it kills all of its students - Robin Williams. tiny ad:
Rocket Oven Kickstarter - from the trailbosshttps://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss