This is something that most of us probably already know but is worth restating just in case. When cloning (a practice that generally I'm personally not all that keen about) a one dimensional array of primitives you get effectively a deep copy as the primitives are pass by value. When cloning a 2 dimensional array of primitives (for instance int[][]) you get a shallow copy because the inner arrays are objects and just are pass by reference. It's easy to forget because of the way the array is declared. The example below shows this in action:

package example;

public class ArrayClone {

 
public ArrayClone() {
   
singleDimension();
    System.out.println
();
    multipleDimensional
();
 
}
 
 
private void singleDimension() {
   
int[] a = new int[]{ 1, 2, 3 };
   
int[] b = a.clone();
   
    System.out.println
( "After clone: a[ 1 ] = " + a[ 1 ] + " b[ 1 ] = " + b[ 1 ] );
   
    b
[ 1 ] = 7;
   
if( a[ 1 ] == b [ 1 ] ) {
     
System.out.println( "Clone failed: a[ 1 ] = " + a[ 1 ] + " b[ 1 ] = " + b[ 1 ] );
   
} else {
     
System.out.println( "Clone worked: a[ 1 ] = " + a[ 1 ] + " b[ 1 ] = " + b[ 1 ] );
   
}
  }
 
 
private void multipleDimensional() {
   
int[][] a = new int[][]{ { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } };
   
int[][] b = a.clone();
   
    System.out.println
( "After clone: a[ 1 ][ 1 ] = " + a[ 1 ][ 1 ] + ", b[ 1 ][ 1 ] = " + b[ 1 ][ 1 ] );
   
    b
[ 1 ][ 1 ] = 7;
   
if( a[ 1 ][ 1 ] == b [ 1 ][ 1 ] ) {
     
System.out.println( "Clone failed: a[ 1 ][ 1 ] = " + a[ 1 ][ 1 ] + ", b[ 1 ][ 1 ] = " + b[ 1 ][ 1 ] );
   
} else {
     
System.out.println( "Clone worked: a[ 1 ][ 1 ] = " + a[ 1 ][ 1 ] + ", b[ 1 ][ 1 ] = " + b[ 1 ][ 1 ] );
   
}
  }
 
 
/**
   *
@param args
   */
 
public static void main(String[] args) {
   
new ArrayClone();
 
}

}