Linked Questions

972 votes
25 answers
908k views

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 ...
blekione's user avatar
  • 10.6k
22 votes
2 answers
80k views

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 ...
MasonAlt's user avatar
  • 369
2 votes
1 answer
1k views

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( ...
DisasterCoder's user avatar
42 votes
1 answer
119k views

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 ...
user2976389's user avatar
0 votes
10 answers
11k views

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. * ...
Gaurav Tiwari's user avatar
1 vote
4 answers
4k views

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....
chamara's user avatar
  • 11
1 vote
2 answers
2k views

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 ...
javaGuy123456's user avatar
0 votes
1 answer
1k views

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() ...
LocalHost's user avatar
  • 920
2 votes
4 answers
774 views

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 ...
Nick Dong's user avatar
  • 3,796
-3 votes
2 answers
413 views

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 ...
Jacob's user avatar
  • 7
0 votes
2 answers
144 views

I have this code: import java.util.*; public class Vormpjes { public static void main(String[] args){ String vorm; String nogmaals; double diameter; double ...
user3024879's user avatar
-1 votes
1 answer
197 views

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 ...
Olof's user avatar
  • 1
0 votes
1 answer
134 views

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 ...
Darien Springer's user avatar
0 votes
5 answers
115 views

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 ...
user3672822's user avatar
0 votes
4 answers
96 views

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 ...
bman's user avatar
  • 1

15 30 50 per page