Custom Linklist class error
<pre><code>class Link {
    public Link next;    
    public String data; 
}

public class LinkedList {
    public static void main(String[] args) {
        String myArray[] = new String[2];
        myArray[0] = "John";
    myArray[1] = "Cooper";

        Link first = null;    
        Link last  = null;    

        while (myArray.hasNext()) {
            String word = myArray.next();

            Link e = new Link();    
            e.data = word;          

            //... Two cases must be handled differently
            if (first == null) {
                first = e;            
            } else {
                //... When we already have elements, we need to link to it.
                last.next = e;       
            }
            last = e;                
        }

        System.out.println("*** Print words in order of entry");
        for (Link e = first; e != null; e = e.next) {
            System.out.println(e.data);
        }

    }
}
</code></pre>

<blockquote>
  <p>LinkedList.java:16: cannot find symbol symbol  : method hasNext()
  location: class java.lang.String
          while (myArray.hasNext()) {
                           ^ LinkedList.java:17: cannot find symbol
  symbol  : method next() location: class java.lang.String
              String word = myArray.next();
                                      ^ 2 errors</p>
</blockquote>

<p>Few Questions... </p>

<ol>
<li>Why did this error occur, i am trying to pass my Array of Strings. Still its not taking.</li>
<li><p>Can't we not declare Array of Strings like in JavaScript  way.</p>

<p>String myArray[] = ["assa","asas"];</p></li>
<li><p>What does the hasNext() and the next Method do?</p></li>
</ol>
