// various ways of cloning arrays, or parts of arrays.
import java.util.Arrays;
...

int [] values = { 10 , 20, 30, 40, 50 };

// cloning an array with .clone.  You must cast from Object to int[].
int [] aCopy1 = (int[])values.clone();

// cloning with Arrays.copyOf, JDK 1.6+
int [] aCopy2 = Arrays.copyOf( values, values.length );

// cloning with Arrays.copyOfRange, JDK 1.6+
int [] aCopy3 = Arrays.copyOfRange( values, 0, values.length );

// cloning with System.arraycopy. Note the lower case c in copy.
// src, srcPos, dest, destPos, length
int [] aCopy4 = new int[ values.length ];
System.arraycopy( values, 0, aCopy4, 0, values.length );

// -30-