private static Object cloneSerializableObject(Object o) throws IOException, ClassNotFoundException {
  ByteArrayOutputStream b=new ByteArrayOutputStream();
  ObjectOutputStream out=new ObjectOutputStream(b);
  out.writeObject(o);
  out.flush();
  out.close();
  ByteArrayInputStream bi=new ByteArrayInputStream(b.toByteArray());
  ObjectInputStream in=new ObjectInputStream(bi);
  return in.readObject();
}

private static Object cloneSerializableObject ( Object o ) throws IOException , ClassNotFoundException { ByteArrayOutputStream b = new ByteArrayOutputStream ( ) ; ObjectOutputStream out = new ObjectOutputStream ( b ) ; out . writeObject ( o ) ; out . flush ( ) ; out . close ( ) ; ByteArrayInputStream bi = new ByteArrayInputStream ( b . toByteArray ( ) ) ; ObjectInputStream in = new ObjectInputStream ( bi ) ; return in . readObject ( ) ; }
this methods provide cloning for serializable objects . mail attributes are serializable but not clonable so we need a deep copy
