title: How do you Externalize a List in Java
body: <p>I have a class which implements Externalizable which contains three objects and a List of one of those three object types. I have assumed you would simply implement externalizable in the sub classes and then define read and write external for the member objects but is it possible to also include the List and if so how?</p>
  <pre><code>public class AuthSuccessPacket extends Packet implements Externalizable {
  
  public static final long serialVersionUID = 10003L;
  Contact contact;
  Network network;
  Account account;
  List&lt;Contact&gt; contacts;
  
  public AuthSuccessPacket(){
      super(Type.AUTH_SUCCESS);
  }
  
  public AuthSuccessPacket(Contact contact, Network network, Account account, List&lt;Contact&gt; contacts){
      super(Type.AUTH_SUCCESS);
      this.contact = contact;
      this.network = network;
      this.account = account;
      this.contacts = contacts;
  }
  
  @Override
  public void writeExternal(ObjectOutput out) {
    out.writeObject(account);
    out.writeObject(network);
    out.writeObject(contact);
  // ??? write list
  }
  
  @Override
  public void readExternal(ObjectInput in)  {
  }
  contact = (Contact) in.readObject();
  network = (Network) in.readObject();
  account = (Account) in.readObject();
  // ??? read list
  }
  </code></pre>