Skip to content
Advertisement

Tag: java.util.scanner

How to handle empty scanner input strings in java?

I’m working on a .xml file generator. It works by asking the user to input 5 different values and then using them for generating a .xml data container. This is the code: I want the program to detect when someone inputs an empty string by pressing the enter key with no written text and print a message asking the user

Output is not showing for second array in Java

I’m a beginner in Java programming and I created a program that accepts 10 numbers as input from users and prints them. The first section is using for loop and the second section is using while loop. The first section works properly and the second section isn’t displaying output. Could anybody help me? } Answer You are not resetting variable

Can’t input anything after the User obj3 = new User(); part

i cannot input anything after the User obj3 part. Can anyone help me on what’s wrong with it? i didn’t know what to do already. Answer It looks like a problem with the way you used Scanner. I tried to run this myself (with User and Administrator commented out), and it skipped over the ID: and Password: inputs. Scanner has

Extraction of string and integer from txt

I’m trying to make a simple scanner reader to read from a txt stored in C:UsersjamesDesktopprojectfiles and it’s called data “data.txt”, the thing is that the information stored is like this: So as you can see the spaces between the string and the integer that I want o extract are random. I was trying to make this: But the split

Advertisement