title: Check if String contains exact key word
body: <p>I have a List of Strings. For each string i wish to see if the first occurrence of the word "joe" is present. I am separating by white space as I do not wish to count the word "joey", for example.</p>
  
  <p>My current code counts every occurrence of the word "joe", how do I edit it so it only counts the first occurrence of the word, and then moves onto the next string in the list. </p>
  
  <pre><code>public int counter(List&lt;String&gt; comments) {
      int count = 0;
      String word = "joe";
      for (String comment : comments) {
          String a[] = comment.split(" ");
  
          for (int j = 0; j &lt; a.length; j++) {
  
              if (word.equals(a[j])) {
                  count++;
  
              }
          }
          System.out.println(comment);
      }
      System.out.println("count is " + count);
      return count;
  }
  </code></pre>
  
  <p>EDIT</p>
  
  <pre><code>str.add("the hello my the name is joe the this joe is a test");
  str.add("i was walking down joe then suddenly joe said hi");
  </code></pre>
  
  <p>I want my code to return 2 for this (joe has appeared in each String)</p>