Skip to main content

Questions tagged [java.util.scanner]

A simple text scanner in the JDK which can parse primitive types and strings using regular expressions.

0 votes
1 answer
39 views

How to get Java console scan 2 strings separated by TAB key

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
-2 votes
0 answers
60 views

Which way should slashes be? [duplicate]

im learning java and am curious about something. like with slashes in file paths. i know that im supposed to use / in the code. but what about when reading in a file path from another file? so like i ...
yellowHoggerz's user avatar
0 votes
0 answers
19 views

Scanner doesn't take input after first round of the for loop [duplicate]

I want to run a block of code which repeats until user wants to exit themself. So I put it into a for loop where it'll keep iterating until user enters 0 as a choice. It works fine in the first ...
Abhay Sahu's user avatar
0 votes
0 answers
29 views

Why are my output values displaying E when they shouldn't be that long? [duplicate]

When running a program for calculating investor loans, my program provides an output of owner future value that is extremely long and contains an "E". I'm not sure if my formulas are wrong ...
vin's user avatar
  • 11
-2 votes
0 answers
40 views

Using if statement on scanner. I write the correct word but if statement fails [duplicate]

So, I'm trying to make a simple scanner password where you input the password and if written correctly it should print out a message If you input the correct password the code should print a message. ...
EBJ EBJ's user avatar
-1 votes
1 answer
99 views

Java Scanner throws IndexOutOfBoundsException if an asynchronous thread is interruped while waiting on nextLine() and another nextLine() is called

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
0 votes
0 answers
27 views

can anyone explain why the string input taken after integer input in java gives error [duplicate]

Why does attempting to take a string input after an integer input using Scanner in Java often result in unexpected behavior or errors? What are the underlying details of this problem?" I ...
SIDDHANT SINGH's user avatar
0 votes
0 answers
33 views

I encountered a strange problem while using Scanner in java. Its displays the phrase twice [duplicate]

Code import java.util.Scanner; public class sortirovka { public static void main(String[] args){ int[] massiv = new int[10]; Scanner cons = new Scanner(System.in); for(int ...
vnightly's user avatar
0 votes
1 answer
61 views

how to use ? and : expression in java

I want to use ? : expression instead of if with 4 conditions in this code but i dont know how< any answers please? import java.util.Scanner; public class Ex13 { public static void main(String[] ...
Mohammad Naser's user avatar
-1 votes
1 answer
45 views

How to populate an array automatic with an user` input?

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
0 votes
0 answers
19 views

how take two string input from user [duplicate]

import java.util.Scanner; public class userInput { public static void main(String[] args) { // TODO Auto-generated method stub Scanner obj = new Scanner(System.in); ...
lokhande_rutu's user avatar
1 vote
2 answers
59 views

Running a console application (CLI) from docker-compose

Have java code: public class Hello { public static void main(String[] args) { System.out.println("Enter Name"); Scanner reader = new Scanner(System.in); String s ...
Арсений Коротков's user avatar
-1 votes
1 answer
97 views

Why isn't "\n" interpreted as newline character when a String like, "abc\nabc" is given as input via Scanner class in Java?

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
0 answers
37 views

Inputs from console do not become String in program through nextLine

I am making a program that first asks the user to input a number from the console to choose which umber type they'd like to convert to the other two, after which the user enters a number in the form ...
Aidan Devine's user avatar
0 votes
1 answer
107 views

SIGHUP error handling, exception throws in Scanner class how can I fix this problem?

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

15 30 50 per page
1
2 3 4 5
433