title: Finding the indexes of multiple words in a string
body: <p>I swear I did this a while back and it worked. But I can't remember how I did it. I want to find the indexes of multiple words in a string. The code below only works for one word. I need a more eloquent solution for dealing with several.</p>
  
  <pre><code>import java.util.*;
  
  public class test {
  
      public static List&lt;List&lt;Boolean&gt;&gt; work;
  
      public static void main (String[] args) {
          String test = "I'm trying to both extract and replaces. This that and the other";
          String word = "I'm";
  
          for (int i = -1; (i = test.indexOf(word, i + 1)) != -1; ) {
  
  
              System.out.println(i);
          }
      }
  }
  </code></pre>
  
  <p>Let's say I wanted to find the index of “both” and “other.”</p>