title: A method that return single words from a String
body: <p>As I mentioned in the title, i want to create a method in java that find each word from a String and print it out.</p>
  
  <p>That is how it (more less) look like: </p>
  
  <pre><code>public int findFirstLetter(int pos, String text)
  {
      while (pos&lt;text.length())
      {
          if (Character.isLetter(text.charAt(pos))==true&amp;&amp;(pos == 0||Character.isLetter(text.charAt(pos-1))==false)){return pos;}
          pos++;
      }
      return -1;
  }
  public int findLastLetter(int pos, String text)
  {
      while (pos&lt;text.length()){
          if (Character.isLetter(text.charAt(pos))==true&amp;&amp;(pos+2&gt;text.length()||Character.isLetter(text.charAt(pos+1))==false)){return pos;}
          pos++;
          if (pos == -1){break;};    
      }
      return -1;
  }
  public void testString (String text)
  {
      int first = findFirstLetter(0,text);
      int last = findLastLetter(0,text);
      String word = "";
      int startWord = 0;
      int i = 0;
      while (first!=-1)
      {
          word = text.substring(first, last+1);
          System.out.println("word: "+word);
          startWord = text.indexOf(word)+1;
          first = findFirstLetter(startWord,text);
          if(first == -1){break;}
          last = findLastLetter(first,text);
      }
  </code></pre>
  
  <p>When i provide some String as input to this method, the loop is starting to repeat from the middle and doesn't reach the end. For example, in the last phrases the method is repeating "the loop is" over and over again. Could someone give me some advice in order to find what is wrong? </p>