Exception when attempting to run code. String Index out of range
<p>Whenever I try to run the code, it gives me an error after I input how many tickets I would like to buy. This is for a lottery program. Here is the code </p>

<pre><code>import java.util.Scanner;
public class Lottery {
public static void main(String[] args) {
    //local data
    String guess;
    int numTickets;
    int counter;
    Scanner in = new Scanner(System.in);

    //output
    System.out.println("How many tickets would you like to buy?");
    numTickets = in.nextInt();
    for (counter = 0; counter &lt; numTickets; counter++) {
        System.out.println("Please enter your three numbers (e.g. 123): ");
        guess = in.nextLine();
        int randNum = (int) (Math.random() * 1000);
        String randNumb;
        randNumb = Integer.toString(randNum);
        char ch1 = randNumb.charAt(0);
        char ch2 = randNumb.charAt(1);
        char ch3 = randNumb.charAt(2);

        if (ch1 == guess.charAt(0) &amp;&amp; ch2 == guess.charAt(1) &amp;&amp; ch3 == guess.charAt(2)) {
            System.out.print("Winner: " + randNumb);
            System.out.print("Congratulations, both pairs matched. /n");
        } else if (ch3 == guess.charAt(2) &amp;&amp; ch2 == guess.charAt(1)) {
            System.out.print("Winner: " + randNumb);
            System.out.print("Congratulations, the end pair matched.");
        } else if (ch1 == guess.charAt(0) &amp;&amp; ch2 == guess.charAt(1)) {
            System.out.print("Winner: " + randNumb);
            System.out.print("Congratulations, the first pair matched.");
        } else {
            System.out.print("The Correct Number: " + randNumb);
        }
        System.out.println("\t Sorry, no matches,  You only had");
        System.out.println("\t one chance out of 100 to win anyway.");

       }
    }
}
</code></pre>

<p>Exception:</p>

<blockquote>
  <p>Exception in thread \"main" java.lang.StringIndexOutOfBoundsException:
  String index out of range: 0  at
  java.lang.String.charAt(String.java:658)  at
  lottery.Lottery.main(Lottery.java:32)
  C:\Users\Ben\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53:
  Java returned: 1</p>
</blockquote>

<p>This is the exception error displayed when I try to run the program.
Help would be much appreciated!</p>