Parse a string and cast certain elements to int
<p>I was working on a bit of code where you would take an input of 2 numbers, separated by a comma, and then would proceed to do other actions with the numbers.</p>

<p>I was wondering how I would parse the string to take the first number up to the comma, cast it to and int and then proceed to cast the second number to an int.</p>

<p>Here is the code I was working on:</p>

<pre><code>    Scanner Scan = new Scanner(System.in);
    System.out.print("Enter 2 numbers (num1,num2): ");

    //get input
    String input = Scan.nextLine();

    //parse string up to comma, then cast to an integer
    int firstNum = Integer.parseInt(input.substring(0, input.indexOf(',')));

    int secondNum = Integer.parseInt(Scan.nextLine());
    Scan.close();

    System.out.println(firstNum + "\n" + secondNum);
</code></pre>

<p>The first number is cast to an integer just fine, I run into issues with the second one.</p>

<pre><code>Exception in thread "main" java.lang.NumberFormatException: For input string: ""
</code></pre>

<p>How would I be able to then take the second integer out of the input string and cast it to an Int. </p>