title: Cannot access variable, initialization not found
body: <p>Program overview: Ask user for phrase, ask user for an index in which a scramble will rotate the phrase until that letter at index is the first index (0) of the string. Ask for an Integer until an integer is given. After phrase is scrambled ask to scramble again. if yes, scramble to inputted index, if no, print final result end program.</p>
  <pre><code>import java.util.Scanner;
  
  public class PJ {
  
    public static void main(String[] args) {
  
      Scanner scan = new Scanner(System.in);
      String phrase;
      String phraseMut;
      int index;
  
      System.out.println(&quot;Enter your word or phrase: &quot;);
      phrase = scan.nextLine();
      phraseMut = phrase;
      System.out.println();
  
      while (true) {
        System.out.println(&quot;Enter the index of a character in your phrase: &quot;);
        if (scan.hasNextInt()) {
          index = scan.nextInt();
          scan.nextLine();
          break;
        } else if (index &gt;= phraseMut.length()) {
          System.out.println(&quot;Error: Index is Double not Integer.&quot;);
        } else {
          System.out.println(&quot;Error: Index is not Integer.&quot;);
        }
      }
  
      System.out.println();
      System.out.println(&quot;Rotating phrase to bring index &quot; + index + &quot; to the front. . .&quot;);
  
      int count = 0;
  
      for (int i = 0; i &lt; index; i++) {
        phraseMut = phraseMut.substring(1, phrase.length()) + &quot;&quot; + phraseMut.substring(0, 1);
        count++;
        System.out.println(phraseMut);
      }
    }
  }
  </code></pre>
  <p>First for loop, I cannot access &quot;index&quot; as the compiler is stating it may not have been initialized. Any solution to access this?</p>