This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori 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.