Originally posted by d jones:
I think 2 objects are being created on this line:
1. new X() is creating an object which is a parameter in the getX method
2. The object which is returned from the getX method is being assigned to the reference variable x.
Therefore is it correct to say that there are 2 objects created here?
Many Thanks
It really depends on what the getX() method does. Maybe it is returning the object that you passed to it. Maybe it is returning an X object that was passed in a previous method call. Maybe it is returning null. Without a clue on what the getX() method does, you don't know if it is creating another object or not.
So yes, the code for the getX() method is relevant to answer your question.
Henry
[ September 19, 2006: Message edited by: Henry Wong ]