Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
33 views

I’m learning Java and testing basic input handling. I wrote the following simple program: import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner ...
Burak HINGE's user avatar
1 vote
2 answers
96 views

The diffrence in the code is in the deleteInput()-Method. Everything else is the same. The question is at the end, because it's about the console output. The code: public class DeletePreviousInputs { ...
Ian's user avatar
  • 23
0 votes
1 answer
60 views

I'm trying to write a calculator In Java, but I don't understand how to provide infinite input of double and string in turn. It keeps throwing InputMismatchException, I don't know what to do. public ...
Матвей Шавлов's user avatar
1 vote
1 answer
71 views

I have the following simple Java program, which asks for a username (via the Scanner) and a password (via the Console). Note I am NOT running this in an IDE such as eclipse, so that bug does not apply ...
Z Star's user avatar
  • 21
0 votes
1 answer
74 views

I have a string that needs to be read using the Scanner class from the beginning to the \n character. The problem is that the source stream in my case may contain the character \u2028. I know that the ...
Smetana Po Aktsii's user avatar
-1 votes
1 answer
62 views

I cannot type the TAB key into the console for 2 strings separated by the tab key, i used the split method but it didn't work. The Java console does not accept the TAB key. Here's a snippet of my code ...
Sơn Trần's user avatar
0 votes
1 answer
139 views

What title says. Java Scanner throws IndexOutOfBoundsException if an asynchronous thread is interrupted while waiting on nextLine() and another nextLine() is called. Here is some code that reproduces ...
Bill Da Scerno's user avatar
-1 votes
1 answer
241 views

i m writing a code as homework, the task is to create a code, where the user give a number (for example 4 ) and the output will be all the number from 4 ( the users input ) till the length of array (...
Reffert's user avatar
-1 votes
1 answer
213 views

In Java, when we try to print a Hardcoded String like, "abc\nabc", we observe a line change after the first abc but when we take same input via sc.next() or sc.nextLine() it prints out '\n' ...
Digvijay Singh's user avatar
0 votes
1 answer
551 views

import java.util.*; class GFG { public static void main (String[] args) { Scanner sc = new Scanner(System.in); String name=sc.next(); System.out.println("No ...
Swati's user avatar
  • 1
0 votes
1 answer
68 views

The following inputs are supplied to this piece of code: 5 0 4 15 1 0 14 2 7 3 23 2 0 7 3 1 23 4 16 4 2 15 3 9 The problem is that whenever the line number is odd, the first integer will not be read ...
Goamhobala's user avatar
0 votes
2 answers
77 views

I am working on a simple project in Java which need to take in a string through a Scanner object and then sort out the inputs which can be integers. These then need to be fed in pairs to run the ...
Steven Meesters's user avatar
-2 votes
1 answer
116 views

I've come across an issue with my scanner functionality. Even after entering "exit" in the terminal, the scanner keeps running. My suspicion is that this behavior is linked to the ...
dracule22's user avatar
-1 votes
1 answer
65 views

My problem is that whenever I try to catch the exception on "scannerGettingStarted", I always get the try catch exception from runProgram. I know that there is a recursion that is happening, ...
CarlKilla's user avatar
0 votes
0 answers
25 views

Basically the issue is that once the main method completes, it prompts to restart the code or not, except it terminates after prompting, no matter what I enter. How do I fix this? import java.awt....
Luka's user avatar
  • 1
1 vote
0 answers
26 views

I have a program that is supposed to give a user three chances to get a password before it locks them out, but the code is only correctly getting the password on the first attempt. import java.util....
Robocittykat's user avatar
4 votes
1 answer
103 views

i tried to creating a new scanner after i closed the former in the main. but it gives error. i thought that i created a new scanner in the method than i closed it so it would read the new inputs ...
Fatih çağlar's user avatar
0 votes
2 answers
96 views

public void readItemData() { try { Frame frame = null; FileDialog fileBox = new FileDialog(frame ,"Open", FileDialog.LOAD); fileBox.setVisible(...
Massiveegg9's user avatar
0 votes
2 answers
123 views

I have some code that runs an addition or subtraction of two numbers based on a user's input, wherein they can either type a String followed by an integer to perform an operation, OR just a String to ...
Babbit's user avatar
  • 3
0 votes
0 answers
24 views

I'm trying to write request, which user can see in console and in the same line he can give response, but I have some issues with that. import java.util.Scanner; public class Main { final static ...
Ruzvelt's user avatar
  • 25
0 votes
0 answers
47 views

I am new to Java and I am doing hospital software in console app. I got a class to select options. The exception is thrown only when option 2 is selected. I don't want the code to stop, but continuing ...
Todor's user avatar
  • 1
0 votes
1 answer
65 views

I know that there's similar questions, but my while loop times out when using HasNextLine() and none of the solutions online have fixed it so far. public static main(String [] args) { Scanner s = ...
David Pascual's user avatar
0 votes
0 answers
37 views

In this simple code, I'm checking if a Scanner has something in the input buffer or not. So I used hasNext() to check whether it has something or not. But instead of returning "false" (in ...
Rachid's user avatar
  • 51
0 votes
2 answers
51 views

If I have a System.out.println("what's your name"), I want the next line to say ">" so it makes it more obvious that it's the users turn to type something. So far I've just put &...
Jacob's user avatar
  • 1
1 vote
3 answers
145 views

I have requirement to read from the scanner based on new line only if its out side the double quotes. Input : "Content1 \r\n block" \r\n Contentn2 \r\n New Content " \r\n Conetent3&...
Siva Ram's user avatar

1
2 3 4 5
130