title: Combine two classes in Java?
body: <p>I don't know what the right way to ask this but I have two classes I get back from the API that both have <code>name</code> as the thing in common but also have another field that is separate from each other. What is the best way to "combine" them where my User class can get the <code>name</code> but can also get their own variables.</p>
  
  <p>How would my <code>User</code> class look? I'm looking for the <code>User</code> class to have <code>name</code> in-common, the Alien class have <code>alienVariable</code> and the Human class have the <code>humanVariable</code></p>
  
  <p>My example of two classes</p>
  
  <p>Alien</p>
  
  <pre><code>@AutoValue
  public abstract class Alien implements Parcelable {
      public static Alien create(String alienVariable) {
          return new AutoValue_Alien(alienVariable);
      }
  
      public static Alien create(String name, String alienVariable) {
          return new AutoValue_Alien(name, alienVariable);
      }
  
      public static TypeAdapter&lt;Alien&gt; typeAdapter(Gson gson) {
          return new AutoValue_Alien.GsonTypeAdapter(gson);
      }
  
      @SerializedName("name")
      public abstract String name();
  
      @Nullable
      @SerializedName("alien_variable")
      public abstract String alienVariable();
  }
  </code></pre>
  
  <p>Human</p>
  
  <pre><code>@AutoValue
  public abstract class Human implements Parcelable {
      public static Human create(String humanVariable) {
          return new AutoValue_Human(humanVariable);
      }
  
      public static Human create(String name, String humanVariable) {
          return new AutoValue_Human(name, humanVariable);
      }
  
      public static TypeAdapter&lt;Human&gt; typeAdapter(Gson gson) {
          return new AutoValue_Human.GsonTypeAdapter(gson);
      }
  
      @SerializedName("name")
      public abstract String name();
  
      @Nullable
      @SerializedName("human_variable")
      public abstract String humanVariable();
  }
  </code></pre>
  
  <p>User?</p>