title: How to return List<Impl> for List<interface>
body: <p>The following code is pretty useless and not tested. It should only explain the problem.
  I want to hide the implementing classes from the application, but define the hierarchy.</p>
  
  <p>Given following interfaces</p>
  
  <pre><code>public interface RowType {
      Integer getSumFromHere();
  }
  
  public interface TableType {
      List&lt;RowType&gt; getRows();
  }
  </code></pre>
  
  <p>Implemented by</p>
  
  <pre><code>public class RowImpl implements RowType {
  
      private Integer value = 0;
      private RowImpl nextRow;
  
      public RowImpl someFunctionNotInInterface() {
          return nextRow;
      }
  
      @Override
      public Integer getSumFromHere() {       
          return nextRow == null ? value : value + nextRow.getSumFromHere();
      }
  }
  
  public class TableImpl implements TableType {
  
      List&lt;RowImpl&gt; implList = new ArrayList&lt;&gt;();
  
      public void doSomethingOnImpl (){
        for(RowImpl row : implList) {
          row.someFunctionNotInInterface();
        }
      }
  
      @Override
      public List&lt;RowType&gt; getRows() {
          return implList;
      }  
  }
  </code></pre>
  
  <p>The implementation of getRows() leads to an error <code>"cannot convert from List&lt;RowImpl&gt; to List&lt;RowType&gt;"</code>
  In fact, it`s guaranteed that every entry in the implList can be accessed through the interface RowType, so it could work.</p>
  
  <p>I tried <code>&lt;? extends RowType&gt;</code> but that's not compatible to the TableType interface.
  Of course I can simple solve the problem, by copying the list <code>return new ArrayList&lt;&gt;(implList);</code> but that's not the same as having a reference to the list held by the class.</p>
  
  <p>Is there a solution for this, or is the design completely wrong ?</p>
  
  <p>edit: Added function in TableImpl that clarifies why the list is build on RowImpl and not on RowType.</p>