title: Java string index out of range: 0
body: <p>I have this problem where as soon as I enter my first input the program crashes and I get </p>
  
  <blockquote>
    <p>String index out of range: 0</p>
  </blockquote>
  
  <p>I've looked elsewhere and tried to find my mistakes but I found different problems which aren't what I had. Could someone please tell me where have I gone wrong?.</p>
  
  <p>Thanks for your help, here is the code:</p>
  
  <pre><code>import java.util.Scanner;
  
  public class Assignment1Q2 {
  
      public static void main(String[] args) {
  
          System.out.println("Thank you for your call,\nPlease take some time to answer a few questions");
          collectData();
  
      }//end of main
  
      public static void collectData() {
  
          Scanner userInput = new Scanner(System.in);
  
          int age;
          char gender;
          char show;
          int over30MY = 0, over30FY = 0, under30MY = 0, under30FY = 0;
          int over30MN = 0, over30FN = 0, under30MN = 0, under30FN = 0;
  
          System.out.println("\nWhat is your age?\n");
          age = userInput.nextInt();
  
          System.out.println("Male or Female (Enter M or Y)");
          gender = userInput.nextLine().charAt(0);
          gender = Character.toLowerCase(gender);
  
          System.out.println("Do you watch the show regularly? (Enter Y or N)");
          show = userInput.nextLine().charAt(0);
          show = Character.toLowerCase(show);
  
          if((age &gt; 30) &amp;&amp; (gender == 'm') &amp;&amp; (show == 'y')) {       
              over30MY++;             
          }
          else if((age &gt; 30) &amp;&amp; (gender == 'f') &amp;&amp; (show == 'y')) {
              over30FY++;
          }
          else if((age &lt; 30) &amp;&amp; (gender == 'm') &amp;&amp; (show == 'y')) {
              under30MY++;
          }
          else if((age &lt; 30) &amp;&amp; (gender == 'f') &amp;&amp; (show == 'y')) {
              under30FY++;
          }
          else if((age &gt; 30) &amp;&amp; (gender == 'm') &amp;&amp; (show == 'n')) {
              over30MN++;
          }
          else if((age &gt; 30) &amp;&amp; (gender == 'f') &amp;&amp; (show == 'n')) {
              over30FN++;
          }
          else if((age &lt; 30) &amp;&amp; (gender == 'm') &amp;&amp; (show == 'n')) {
              under30MN++;
          }
          else if((age &lt; 30) &amp;&amp; (gender == 'f') &amp;&amp; (show == 'n')) {
              under30FN++;
          }//end of if else
  
      }//end of collectData
  }// end of class
  </code></pre>