title: Using enhanced for loop to search LinkedList
body: <p>So im trying to replace a for loop with a enhanced for loop and i cant get it to work, the problem is that it does search and when it finds the name im looking for it returns inex -1. With the normal for loop it returns the correct index. n is the string passed to the method, array is the linkedlist</p>
  
  <pre><code>boolean found= false;
      for(O o: array) {
          if(o.getString().equals(n)) {
              System.out.println("\n"+n+ " is found at position " +array.indexOf(name)+"\n");
              found = true;
          }
      }
  
      for (int i = 0; i&lt;array.size();i++) {
          if((array.get(i).getString()).equals(n)) {
              System.out.println("\n"+n+ " is found at position " +i+"\n");
              found = true;
          }
      }
  </code></pre>