title: Store indexes in an array
body: <p>I need help on how I can store the indexes of a particular word occurring in a sentence.
  I need to store the indexes in an array so that I can access it later. I'm using a while loop but its not working.</p>
  
  <pre><code>while (index &gt; 0) {
  
              for (int i = 0; i &lt; data.length; i++) {
  
                  data[i] = index;
  
              }
  
              System.out.println("Index : " + index);
  
  
              index = input.indexOf(word, index + word.length());
  
          }
  </code></pre>