title: Is custom enum Serializable too?
body: <p>I understand <code>Enum</code> is Serializable. Hence, it is safe to do so. (selectedCountry is <code>enum Country</code>)</p>
  
  <h2>Original enum without customer member variables</h2>
  
  <pre><code>public enum Country {
      Australia,
      Austria,
      UnitedState;
  }
  </code></pre>
  
  <h2>Fragment</h2>
  
  <pre><code>@Override
  public void onActivityCreated (Bundle savedInstanceState) {
      super.onActivityCreated(savedInstanceState);
      if (savedInstanceState != null) {
          selectedCountry = (Country)savedInstanceState.getSerializable(SELECTED_COUNTRY_KEY);
      }
  }
  
  @Override
  public void onSaveInstanceState(Bundle savedInstanceState) {
      savedInstanceState.putSerializable(SELECTED_COUNTRY_KEY, selectedCountry);
  }
  </code></pre>
  
  <p>However, what if I have non-serializable members in custom enum class? For instance,</p>
  
  <h2>Original enum customer member variables</h2>
  
  <pre><code>package org.yccheok;
  
  import org.yccheok.R;
  
  /**
   *
   * @author yccheok
   */
  public enum Country {
      Australia(R.drawable.flag_au),
      Austria(R.drawable.flag_at),
      UnitedState(R.drawable.flag_us);
  
      Country(int icon) {
          this.icon = icon;
          nonSerializableClass = new NonSerializableClass(this.toString());
      }
  
      public int getIcon() {
          return icon;
      }
  
      public static class NonSerializableClass {
          public NonSerializableClass(String dummy) { this.dummy = dummy; }
          public String dummy;
      }
  
      private final int icon;
  
      public NonSerializableClass nonSerializableClass;
  }
  </code></pre>
  
  <p>I tested. It works. (I tested by printing out all the value of member variables before and after serialization. They are same before and after) </p>
  
  <p><strong>However, I do not understand why it works? As I do not provide proper <code>readObject</code> and <code>writeObject</code>, as required by <code>Serializable</code> interface.</strong></p>
  
  <p>As pointed in Effective Java <em>Item 75: Consider using a custom serialized form</em>, do I need to provide my own <code>readObject</code> and <code>writeObject</code>, if I have custom member variables in my enum?</p>