title: How to check if every odd index in a string has the same letter?
body: <p>I'm working on this program where I need to verify if every odd index in a String has the letter "X". For example if my String is: AXFXTX then I should get a message: "GOOD", if not I should get a message: "BAD". Can anyone tell me what I'm missing please. Thank you in advanced. </p>
  
  <p>Here's my code</p>
  
  <pre><code>import java.util.Random;
  import java.util.Scanner;
  
  public class Program {
  
  public static void main(String[] args) {
  
      Random rand = new Random();
      Scanner scan = new Scanner(System.in);
  
      int min = 1;
      int max = 10;
      int randomNum = rand.nextInt((max - min) + 1) + min;
  
      System.out.println("Random number = " + randomNum);
      System.out.print("Enter a word of " + randomNum + " characters:");
      String myString = scan.nextLine();
  
      while(myString.length() != randomNum){
          System.out.print("Enter a word of " + randomNum + " characters:");
          myString = scan.nextLine();
      }
  
      char[] c  = myString.toCharArray();
      for(int i = 0 ; i &lt; c.length ; i++){
          if(c[i] == 'X'){
              System.out.println("GOOD!");
          }
          else{
              System.out.println("BAD");
          }
      }       
   }
  }
  </code></pre>