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.
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL