title: For loop with a generic array?
body: <p>Going back over my basic ADT stuff here, and trying to kill two birds with one stone by learning Java while I amTrying to write a simple algorithm for a merge sort with a generic linked list ( which I am creating myself). It's proving to be far more difficult than I had first imagined ! Can anyone help me out please ? I will start out working on the basics and will update this post as I get further in.</p>
  
  <p>My code for the generic linked list is as follows :</p>
  
  <pre><code>    public class NodeList&lt;T&gt; {
    private Comparable head;
    private NodeList tail;
    public NodeList( Comparable item, NodeList list ) {
      head = item;
      tail = list;
    }
  
  }
  </code></pre>
  
  <p>I am trying to access this class in another class I have made, which is as follows :</p>
  
  <pre><code>public class MyList&lt;T&gt; {
  
    private NodeList&lt;T&gt; nodes;
    private int size;
    public MyList( ) { 
      nodes = null; 
    }
  
    public MyList(T[] array ){
      for(int countArray = 0; countArray &lt;= array.length() ; countArray++) {
        nodes= new NodeList( value, nodes );
        size++;
      }
    }
  </code></pre>
  
  <p>which should add generic items from an array, using a linked list. Unfortunately, it doesn't and this is the first problem I have encountered. I am getting the error : </p>
  
  <blockquote>
    <p>cannot find symbol  : method length().</p>
  </blockquote>
  
  <p>Can someone give me some advice on how I could fix this?</p>
  
  <p>Many thanks!</p>