How can I take user integer input separated by space in Java | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How can I take user integer input separated by space in Java

Here is the question : 4 1 2 2 4 3 5 5 6 The program should take 4 test cases, each test case should accept two integers separated by space . Please help me with the code I have been trying from past hour .

2nd Nov 2022, 8:38 AM
Heidi
Heidi - avatar
2 Answers
+ 3
Share your try here pls....
2nd Nov 2022, 8:42 AM
Jayakrishna 🇮🇳
+ 2
You can use the nextInt() method of the Scanner class. Example: https://code.sololearn.com/cQgAclDLLxoY/?ref=app
2nd Nov 2022, 3:07 PM
Tibor Santa
Tibor Santa - avatar