Results 1 to 2 of 2
  1. #1
    kmm1977 is offline Member
    Join Date
    May 2010
    Posts
    47
    Rep Power
    0

    Default deep copy in java

    I read that Java makes only reference copies , how can i make a deep copy i


    public class MyEntry {
    public int Id;
    public int Name;

    }

    MyEntry entryObj = MyEntry();
    entryObj.Id = 10;
    entryObj.Name = "A";

    MyEntry entryObjCopy = new MyEntry();
    entryObjCopy = entryObj;

    this will only refere to the original object

    how can i make a deep copy

    Regards
    kmm

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    14,793
    Rep Power
    20

    Default Re: deep copy in java

    Look at the clone method.

Similar Threads

  1. Book for goind deep in Java
    By diogosgp in forum Advanced Java
    Replies: 8
    Last Post: 10-27-2011, 02:25 AM
  2. [SOLVED] Deep copy
    By thorne_ in forum New To Java
    Replies: 5
    Last Post: 06-05-2009, 03:51 PM
  3. Deep copy?!
    By deepthought015 in forum New To Java
    Replies: 3
    Last Post: 05-07-2009, 06:31 PM
  4. Deep Copy Test
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-16-2008, 11:05 PM
  5. Replies: 0
    Last Post: 12-28-2007, 12:25 PM

Posting Permissions

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