File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Cloning multidimension arrays Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Cloning multidimension arrays" Watch "Cloning multidimension arrays" New topic

Cloning multidimension arrays

Shivani Chandna
Ranch Hand

Joined: Sep 18, 2004
Posts: 380
Cloning multidimension arrays results in shallow cloning. Have understood that from below exampls.
Can someone explain using diagram - (like Corey explained the GC concepts on this site...) as to how the shallow copying is working

Produces the following output:
false I2:79
false I22:79

Thanks a lot !

/** Code speaks louder than words */
Michael Ernest
High Plains Drifter

Joined: Oct 25, 2000
Posts: 7292

I don't understand your example. You clone() I2, then test for equality of reference between I2 and I3, which is going to be false. Then you change the value of I2[0] and print it. Then you print out I3[0].

What are you trying to demonstrate?

Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
naraharirao mocherla
Ranch Hand

Joined: Aug 16, 2005
Posts: 45
Hi Shivani
can you please give me Corey's link you mentioned(regarding GC diagrams).
Thanks in advance.

1.Is clone method() included in SCJP 1.4 ?
Shivani Chandna
Ranch Hand

Joined: Sep 18, 2004
Posts: 380
yes i suppose so that the method is included
Here is Corey's Site

-- Shivani
I agree. Here's the link:
subject: Cloning multidimension arrays
It's not a secret anymore!