Free Jobs
Reference


Java Questions: Core Java (182) J2EE (32) EJB (22) Servlet (33) JDBC (35) Hibernate (17) Struts (15) Swing (26) Oracle (12) JSP (36) Other (0)

Question: What is the difference between Shallow copy and deep copy of objects in java

To get the Posted Questions details daily in your mail Click Here

Share this question on Facebook/Twitter/Orkut Bookmark and Share





User: mohit555 Post Date: 21 Feb 2012 06:30

Introduction:
What is the difference between Shallow copy and deep copy of objects in java



Answer:


  Suppose there is an object obj1 and it contains obj_contains_1 and obj_contains_2

  In Java if we are doing Shallow copy of obj1 object then

  new copied object obj2 will be created but for contained object it will

  not create another objects obj_contains_1 and obj_contains_2

  but obj2 will be referencing the same obj_contains_1 and obj_contains_2.

  In Java if we are doing deep copy of obj1 object then

  new copied object obj2 will be created but for contained object it will

  create another objects obj_contains_1 and obj_contains_2

  and obj2 will be containing obj_contains_1_new and obj_contains_2_new

 



About Writer:
Hi All,I am Java Developer From Bangalore


Writer's Link:

Writer's Email:







Comments:




Post Comment





Similar Questions Top QuestionsLatest Questions Other Questions by this Author







www.freejobsreference.com Copyright © 2009-2011 | All Rights Reserved
All content of this website is protected by copyright laws and should not be reproduced in any form or by any means without written permission
(Best viewed in IE 8.0+ or Firefox 3.0+ at resolution of 1024 * 768 or higher)