Splitting a String and Parsing it into an Integer
<p>I have some logic (java.lang.ArrayIndexOutOfBoundsException) error in this part of my code for some reason. I want the user to input anything and have it be split and parsed into an integer. If the user fails to do so ask them again. And if they enter something like "g5 3 76h 23" have the program accept it as 5 3. Or if i can have the program deny this until the user only enters two numbers between 0 and 9 separated by a space, that would be fine aswell. The user also has the option of enetering a "q" to quit.
However, everytime i run it, it appears as if nothing was split into a new array. and I get the error.</p>

<pre><code>/** 
 * Prompts the user for input
 */
public void promptUser() {

// a Scanner object that uses System.in for input.

    Scanner scan = new Scanner(System.in);

// a prompt for the user, asking them for input.

    System.out.print("Pick a coordinate [row col] or press [q] to quit: ");

//         Get input from the user, checking for errors. If the input is
//         correct (e.g., two numbers that in bounds and have not 
//         already been clicked), then call the click method for desired 
//         coordinates. If the user wants to quit the game then make sure 
//         to update the boolean state variable and print out a message.

    String input = scan.next();
    String del = "[\\s,;\\n\\t]+"; // these are my delimiters
    String[] token = input.split(del); // here i will save tokens

    int val0 = 11, val1 = 11;
    boolean tf = true;
    while(tf)
    {
    if(token[0] == "q")
        {
        isRunning = false;
                    System.out.println("Thank you for playing");
        }
    else
        {
        try
            {
            val0 = Integer.parseInt(token[0], 10);
            }
        catch (NumberFormatException nfe)
            {
            // invalid data - set to impossible
            val0 = 11;
            }
        try
            {
            val1 = Integer.parseInt(token[1], 10);
            }
        catch (NumberFormatException nfe)
            {
            // invalid data - set to impossible
            val1 = 11;
            }
        }
    if( !(((val0 &gt;= 0) &amp;&amp; (val0 &lt; rows)) &amp;&amp; ((val1 &gt;= 0) &amp;&amp; (val1 &lt; cols))) )
        {
        System.out.println("Input Invalid, pick a coordinate [row col] or press [q] to quit: ");
        input = scan.next();
        for(int i=0;i&lt;2;i++)
            {
            token = input.split(del);
            }
                }
            else if(false) //atm
                {

                }
            else
        {
                    tf = false;


                }
    click(val0, val1);
    } //while loop
} // promptUser
</code></pre>
