This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
Originally posted by Jothi Shankar Kumar Sankararaj: Ok that is understandable that it will null the second reference. I want to know, won't it affect the reference from the main method?? Why not the reference from the main method be nulled???
Any thoughts on that?
Remember that Java always passes a copy of the reference to the method. So it is a local reference variable that is set to null. The confusion is caused by the fact that the name of the local reference variable (in the parameter list) is the same as the one in the main method, namely a1.