index of a String in a paragraph each time it occurs
<pre><code>String word="i love apples i love orange";
String w=scan.next();
    int index = word.indexOf(w);
    System.out.println (index);
while (index &gt;= 0) {
    System.out.println(index);
    index = word.indexOf(w, index + 1);
}
</code></pre>

<p>so i know that this code will tell me the index of love is (2,17)
but what im looking for is that i want it to return for me the index of the word to be (1,4) that is it counts the strings within the string and not the characters...also i need it to indicate the index each time it finds it like the one above thanks</p>
