import java.util.Arrays; public class CloneTest1 implements Cloneable { private int n = 7; private int[] counts = new int[]{1,2}; public String toString() { return ""; } public CloneTest1 clone() throws CloneNotSupportedException { CloneTest1 cl = (CloneTest1) super.clone(); return cl; } public static void main(String[] args) throws CloneNotSupportedException { CloneTest1 cl1 = new CloneTest1(); CloneTest1 cl2 = cl1.clone(); cl2.n = 8; cl2.counts[0] += cl2.counts[1]; System.out.println("cl1 " + cl1); System.out.println("cl2 " + cl2); } }