title: How to refactor this simple class fields
body: <p>I have a very basic OOP question. I have two classes as follows</p>
  
  <pre><code>public class Class1 {
      private String field1;
      private String field2;
      private List&lt;String&gt; field3; 
      // constructors 
  }
  
  public class Class2 {
      private String field1;
      private String field2;
      private List&lt;Object1&gt; field3; 
      // constructors 
  }
  </code></pre>
  
  <p>The only reason i had to create class2 was because the List in class1 can either be a List of Strings or a List of Object2. Is there a way to et rid of Class2, and have field3 behave as a List of String and also as a List of Object2. </p>
  
  <p>I know i can do something like </p>
  
  <pre><code>public class Class1 {
      private String field1;
      private String field2;
      private List&lt;String&gt; field3; 
      private List&lt;Object1&gt; field4; 
  
      // constructors which are initializing null to either field 3 or field 4
  }
  </code></pre>
  
  <p>But the above doesnt seem clean, as an object instantiated with either list should not have any reference in it of the other List. </p>