0

Java user input

How can I add more than one user input variable in Java? For example: import java.util.Scanner class MyClass { public static void main(String[ ] args) { Scanner h = new Scanner(System.in) System.out.println(h.nextLine()); } } How can I add another user input variable?

21st May 2020, 12:05 AM
Zach Janzen
2 Answers
+ 2
Hello Zach Janzen You can do it when you assign each user input to a variable. String str = h.nextLine(); int num = h.nextInt(); ... and so on.
21st May 2020, 12:18 AM
Denise Roßberg
Denise Roßberg - avatar
0
This really helps me alot.
21st May 2020, 2:57 AM
Zach Janzen