import java.io.*; import java.util.*; class Pair implements Serializable { public Object first; public Object second; } class Holder implements Serializable { public Object value; } public class SerializableTest { public static void main(String[] args) { Date today = new Date(); Holder a = new Holder(); a.value = today; Holder b = new Holder(); b.value = today; Pair c = new Pair(); c.first = a; c.second = b; try { FileOutputStream f = new FileOutputStream("saveState"); ObjectOutputStream s = new ObjectOutputStream(f); s.writeObject("The value of c is"); s.writeObject(c); s.close(); } catch (IOException e) { System.out.println("received error " + e); e.printStackTrace(); } } }