Multiple Java User Input | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Multiple Java User Input

I want to make the user either type in an integer (number) or a text/word. List 1. Name1 (text1) 2. Name2 (text2) 3. Name3 (text3) User input either int (1-3) or name (name1 - name3). After typing that into the system my code displays text1 - text3. But how can the user either type in the number OR the name.

24th Jun 2019, 12:34 PM
Fynn F.
Fynn F. - avatar
3 Answers
+ 2
You can use try and catch
24th Jun 2019, 12:51 PM
Airree
Airree - avatar
+ 2
please help a newbie..I have multiple question for the user to input why is it that only one of them is outputted the first one..?? I also need an explanation to the statement " split multiple inputs in different lines"..really need help here guys.
2nd Jul 2019, 5:54 AM
Allan And Lifted Hands
Allan And Lifted Hands - avatar
+ 1
You can take a text input, and then perform string manipulations in it to know, whether it is an integer or a name.
24th Jun 2019, 12:53 PM
Seb TheS
Seb TheS - avatar