Hi guys,

When I am reading through ImageIO package’s source code, I found out there
are two difference way to return a String[].

For some methods, they call Arrays.clone() to clone a new string[] and
return the new one while some other methods returning the original String[]
directly.

e.g.:
1.
public String[] getFormatNames() {
    return names.clone();
}

2.
public String[] getImageReaderSpiNames() {
    return readerSpiNames;
}

I am wondering what the difference between these two usages is. For what
kind of situations I need to clone a new array ?

Thanks,

Lang

Reply via email to