Please help me whit this java question.
Please help me!
1-Please tell me how and when an object works as parameter.
2-I have also problem whit returning Obejct .
if we have a method like this: it is just an example
public Golf Game(Golf golf)
// compute some thing here
*How dose the Golf object in above method works as parameter
*what dose the method return, and
*when we should write such a method
it will be ever the same object if you don't instance the class again.
Regarding the method you wrote, it takes another Golf object, perform some operations in that method and then return some other Golf Object back to where the method is called.
This kinda mechanism can be used where we need to send another object of same class .
Good Luck :-)
Are you really wanting to return a new Golf object, or are you modifying the exising Golf object (the one you are passing as the argument to the method)? Your code bit indicates you are modifying the existing one - therefore, you would not be creating a new object to return, you'd be modifying the object which was passed - "by reference" - to the method.
If you are going to return a new object you need to create that object, then you would be doing some sort of "copy constructor" to imbue that object with the state of the argument object, then make some modifications, then return the NEW object.
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center