title: Return the first index from arraylist where string was found logic confusion
body: <p>guys so I have this method that I am trying to construct, I am just having a hard time understanding the logic. This is the condition of the method:</p>
  <blockquote>
  <p><strong>public int search(String str)</strong> – search the list for parameter str.
  Searches should work regardless of case. For example, “TOMATO” is
  equivalent to “tomato.”</p>
  <p>Hint: the String class has a method called
  equalsIgnoreCase. If the string str appears more than once in the
  ArrayList, return the first index where the string str was found or
  return -1 if the string str was not found in the ArrayList.</p>
  </blockquote>
  <p>This is what I have so far for my code, I am not sure if this is the right way to do it. My ArrayList is defined as words.</p>
  <p>In order to solve this issue, I am thinking of using a foreach statement to iterate through the ArrayList then an If to check if the words match then return the Index value based on the match but I am getting error. The other confusion I am having is how do I only return the first Index value only. Maybe I am doing this wrong. Any help or direction is appreciated.</p>
  <pre><code> public int search(String str)
      {
          for(String s : words)
          if(s.contains(s.equalsIgnoreCase(str)))
              return s.get(s.equalsIgnoreCase(str));
              
      }
  </code></pre>