I am working on a program and I want to allow a user to enter multiple integers when prompted. I have tried to use a scanner but I found that it only stores the first intege
I use it all the time on hackerrank/leetcode
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String lines = br.readLine(); String[] strs = lines.trim().split("\\s+"); for (int i = 0; i < strs.length; i++) { a[i] = Integer.parseInt(strs[i]); }