 <p>The answer to this is quite simple.</p> <pre><code>Scanner scanner = new Scanner(System.in); public static void main(String[] args) { int line1 = 0; while (true) { String input = scanner.nextLine(); if (input.length &gt; 0) { try { line1 = Integer.parseInt(input); break; } catch (NumberFormatException e) { System.out.println("Input not an integer, try again."); } } else { // User entered nothing. Break loop to stop it from never ending. break; } } String line2 = Scanner.nextLine(); } </code></pre> <p>This will store an integer from the scanner, and forcefully make sure it is an integer, and then store a string afterwards. If you do not correctly enter an integer, it will request another.</p> <p>If you need to later split the string for every whitespace, use:</p> <pre><code>String[] array = line2.split(" "); </code></pre> <p>You cannot split an Integer.</p> <p>If both inputs need to be combined into a single string, then you can then use:</p> <pre><code>String completeString = line1 + " " + line2; </code></pre> <p>And again, you can split this by using:</p> <pre><code>String[] array = completeString.split(" "); </code></pre> <p>So if the user entered 55, and "Hello", you would end up with the following after splitting:</p> <pre><code>["55", "Hello"] </code></pre>