If you want something you never had do something which you had never done
[OCP 17 book] | [OCP 11 book] | [OCA 8 book] [OCP 8 book] [Practice tests book] [Blog] [JavaRanch FAQ] [How To Ask Questions] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
If you want something you never had do something which you had never done
RaviNada Kiran wrote:Hi all ,
If we clone an Object , does the cloned object will be responsible to occupy memory on to the heap ??
Dhruva
Sandeep Kumar Jakkaraju wrote:If the shallow copy and the original object both are different memory locations ....
Does the JVM put extra effort to synchronize both the copies ......
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Sandeep Kumar Jakkaraju wrote:Dear Sir
I mean the same thing ,.......
If you override the clone() method of the Class you are implmenting .... to create a copy ... it is usually a deep copy and there are 2 objects in the JVM occupying the double the memory on the heap .....
I dont expect a layman like me to override the clone() method in each and every class i write so ..... i will always get a shallow copy hence there is only 1 object in the heap with two references pointing to it !!!
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Consider Paul's rocket mass heater. |