public class CloneExample { public static void main(String[] args) { try { Person p = new Person(); p.age=66; p.address = new Address(); Person p2 = (Person)p.clone(); System.out.println(p.age +" " +p2.age); } catch (CloneNotSupportedException e) { // Handle error } } }