Asking user for multiple input
java, java-io
Solution
String str = input.nextLine();
You don't need Scanner a at all. Just replace all the references to it with references to `input`.
Problem
I am trying to write a program which will keep asking a user for an integer until they input a value which isn't an integer, at which point the program stops. Here is what I have so far: ``` import java.util.Scanner; import java.util.ArrayList; public class InputStats { private static Scanner a; public static void main(String[] args) { Scanner input = new Scanner(System.in); ArrayList InputArray = new ArrayList(); Boolean Running = true; System.out.println("Please type an integer. To stop enter a non integer value"); while (Running) { a = Scanner.nextLine(); if (!a.hasNextInt()) { Running = false; } else { InputArray.add(input.nextLine()); } System.out.println(InputArray); } } } ``` However, with this code I am recieving the errors: ``` error: non-static method nextLine() cannot be referenced from a static context (for the line a = Scanner.nextLine();) ``` and ``` error: incompatible types (for the line a = Scanner.nextLine();) ``` What could be the issue?