title: Java - Why declare an array as a type of Interface?
body: <p>This is from Professor Mark Weiss in his book <em>Data Structures and Algorithm Analysis in Java</em></p>
  
  <pre><code>public class BinaryHeap&lt;AnyType extends Comparable&lt;? super AnyType&gt;&gt;{
      private void enlargeArray( int newSize ){
          AnyType [] old = array;
          array = (AnyType []) new Comparable[ newSize ];
          for( int i = 0; i &lt; old.length; i++ )
          array[ i ] = old[ i ];        
      }
  }
  </code></pre>
  
  <p>I was wondering why do we declare an array with a type of interface Comparable since we have to convert the <code>Comparable[]</code> to an <code>AnyType[]</code>? Any design philosophy in there?</p>