Does clone method on array a deep or a shallow copy?

java

Solution

Strings in Java are imutable(Can't change their value). So there is no detectable difference between a deep and shallow copy when copying strings.

And just to further reference: The copy will be shallow but that should not be a problem since strings are imutable.

Oh and funny fact: Strings can't be cloned with the clone method, so if you try to do a deep copy of strings with the clone method, you will get a CloneNotSupportedException.

Problem

I'm not sure if the following will result in deep or shallow copy? ``` public void viewImages(final String[] instancesFilename) { String[] instances = (String[])instancesFilename.clone(); } ``` Is there a simple and fast way to deep copy a string array?

Original source