Linked Questions
16 questions linked to/from Java String Scanner input does not wait for info, moves directly to next statement. How to wait for info?
972 votes
25 answers
908k views
Scanner is skipping nextLine() after using next() or nextFoo()?
I am using the Scanner methods nextInt() and nextLine() for reading input. It looks like this: System.out.println("Enter numerical value"); int option; option = input.nextInt(); // Read ...
22 votes
2 answers
80k views
Java Console Prompt for ENTER input before moving on [duplicate]
I am creating a simply story, which will occasionally prompt the user to hit ENTER. It works the first time I prompt for it, but then it will immediately execute the other prompts, maybe because the ...
2 votes
1 answer
1k views
Java user input nextLine() doesnt wait for input [duplicate]
I have this small problem with my input : public void input() { Scanner scn = new Scanner( System.in ); System.out.print( "Please enter id: " ); id = scn.nextInt(); System.out.print( ...
42 votes
1 answer
119k views
Java Scanner doesn't wait for user input [duplicate]
I am using Java's Scanner to read user input. If I use nextLine only once, it works OK. With two nextLine first one doesnt wait for user to enter the string(second does). Output: X: Y: (wait for ...
0 votes
10 answers
11k views
Error in reading double and string value from standard input?
Here is my code: public class Solution { public static void main(String[] args) { /* * Enter your code here. Read input from STDIN. * Print output to STDOUT. * ...
1 vote
4 answers
4k views
Java Array index out of bounds Exception when getting string input in java
I got an Java ArrayIndexOutOfBoundsException when getting String input in Java. Please help me. This is my code: I edited my code to split using : it says Exception in thread "main" java.lang....
1 vote
2 answers
2k views
Rock paper scissor class using different methods
I am creating a rock paper scissors class for my intro to java homework. I am pretty much done but the option to pick a choice is repeating twice and I am getting the wrong output. Im fairly new to ...
0 votes
1 answer
1k views
next() vs nextLine() in JAVA [duplicate]
I was trying to take input for the number of names to be stored in an array from user and then using that i was taking names from the user ,first i tried to take names from the user using next() ...
2 votes
4 answers
774 views
nextInt() caused an infinit loop
My expectation: If the user types an Int which is not in the right range, the program will give him another chance until the user gives the right type. So, I need a while block. But I got an infinite ...
-3 votes
2 answers
413 views
How to make a calculator [closed]
I am trying to create a calculator for class, we have to show the operation, we have to make it loop back to the top where it says to enter the first number but also give an option to return back to ...
0 votes
2 answers
144 views
Java 'do while' loop not working
I have this code: import java.util.*; public class Vormpjes { public static void main(String[] args){ String vorm; String nogmaals; double diameter; double ...
-1 votes
1 answer
197 views
What's making these functions not work after the first entry? [duplicate]
I have an Arraylist of 3 dogs, and I can register more dogs to the list, list them by calling a toString function, increase the age of a dog by one, and remove a dog from the list. As long as you only ...
0 votes
1 answer
134 views
Java Interaction Not Allowing User Input to be Scanned In
I am designing a simple program where a user inputs a string value for item # 1's name and then an integer value for item # 1's price and then an integer value for item # 1's quantity. When I compile ...
0 votes
5 answers
115 views
Scanning lines in Java
What's wrong with the code? It won't let me write the input for each one of them..I wanted to read how many editions, the year and city of each edition, and it jumps to the loop and won't let me put ...
0 votes
4 answers
96 views
My breaks won't fire after if statement
import java.util.Scanner; public class EmpTest { public static Scanner input = new Scanner(System.in); public static void main(String[] args) { // there is a second class with my ...