Please help me whit this java question.


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Please help me whit this java question.

  1. #1
    Join Date
    Oct 2004
    Location
    sweden
    Posts
    8

    Exclamation Please help me whit this java question.

    Hi!
    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
    return
    }

    *How dose the Golf object in above method works as parameter
    *what dose the method return, and
    *when we should write such a method

  2. #2
    Join Date
    Oct 2004
    Posts
    25
    it will be ever the same object if you don't instance the class again.

    Best regards
    floaty

  3. #3
    Join Date
    Aug 2004
    Location
    On the net
    Posts
    38
    Hi,

    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 :-)

    Narayana

  4. #4
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    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.

    Right?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center