title: find all palindromes in string
body: <p>I need to find all the palindromes in a string. It takes user input</p>
  
  <p><strong>example:</strong> "abbaalla"</p>
  
  <p>it loops through creating a substring that changes as the loop progresses.</p>
  
  <p><strong>example</strong>: checks palindrome "a" (true) "ab"(false) "abb" (false) "abba" (true) and so on..</p>
  
  <p>once it reaches the max length of the word it iterates the start of the substring and repeats</p>
  
  <p><strong>example</strong>: check palindrome "b" "bb" "bba" and so on..</p>
  
  <p>I need to change the code so that once it finds the first largest palindrome ("abba") the start of the loop will take place after that substring. so the next palindrome should read "alla"</p>
  
  <p>the final output should be a string that includes all palindromes. in this case;</p>
  
  <p>output: "abba alla"</p>
  
  <p>Also this program currently results in: String index out of range: -1</p>
  
  <pre><code> public static String findAllPalindromes(String input){
       int indexStart = 0;
       int wordMax = input.length();
       int wordLength;
       String checkPalindrome;
       String allPalindromes = "";
       for (wordLength = 2; wordLength &lt;= wordMax; wordLength++) {
  
           //creates a substring to check against isAllPalindrome method
           checkPalindrome = input.substring(indexStart, wordLength);
           //checks checkPalindrome string to see if it is a palindrome
           if (isAllPalindrome(checkPalindrome) == true){
               allPalindromes += " " + checkPalindrome;
               if (checkPalindrome.length() &gt;= allPalindromes.length()){
                   allPalindromes = checkPalindrome;
               }
           }
           //once program reads string through once, increment index and scan text again
           if (wordLength == wordMax &amp;&amp; indexStart &lt; wordMax){
               indexStart++;
               wordLength = 0;
           }
  
       }
       System.out.println("The palindromes in the text are: ");
       System.out.println(allPalindromes);
       return allPalindromes;
   }
  </code></pre>