Results 1 to 3 of 3

Thread: clone method

  1. #1
    javaplus is offline Member
    Join Date
    Nov 2007
    Posts
    97
    Rep Power
    0

    Default clone method

    clone method creates a copy of the object, but a different object is created. How can I make the cloned object point to the same object from which it was cloned?

  2. #2
    tim's Avatar
    tim
    tim is offline Senior Member
    Join Date
    Dec 2007
    Posts
    435
    Rep Power
    7

    Default Return this

    Hello javaplus

    Override the clone() method of your class:
    Java Code:
    public Object clone(){
        return this;
    }
    This is a bit pointless, but it should do the trick. ;)
    Eyes dwelling into the past are blind to what lies in the future. Step carefully.

  3. #3
    javaplus is offline Member
    Join Date
    Nov 2007
    Posts
    97
    Rep Power
    0

Similar Threads

  1. How to clone an Array
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-14-2008, 09:46 PM
  2. An nslookup clone in Java
    By Java Tip in forum java.net
    Replies: 0
    Last Post: 04-07-2008, 09:12 PM
  3. clone method
    By gapper in forum New To Java
    Replies: 1
    Last Post: 01-20-2008, 09:46 AM
  4. clone problem
    By feniger in forum New To Java
    Replies: 13
    Last Post: 01-13-2008, 11:55 AM
  5. How to clone a JAXB object ?
    By simon in forum Advanced Java
    Replies: 1
    Last Post: 07-15-2007, 12:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •