0
2 Java Scanners
So in java, you can use the scanner thing for input, but how would you do multiple inputs? I know you can do a space in the input and when getting the variable you can use .nextInt(), but I want to know if you can do it like javascript, with multiple prompts and text that explains what you can write
5 Antworten
+ 2
you can use same scanner object multiple times,
Scanner scan = new Scanner(System.in)
System.out.println("first input")
String in1 = scan.nextLine()
System.out.println("second input")
String in2 = scan.nextLine()
I hope this helps :)
+ 1
yup, I agree with Martin Taylor 's answer, this is a limitation with Sololearn's code playground.
+ 1
Oh ok Martin Taylor thx for letting me know :)
0
I'll try it Apollo-Roboto but it doesn't help with the part where it explains what you input, for example in js you can do 'var b = prompt("Turtle");' and the "Turtle" would show up to guide you on what to input, or is it not possible?
Edit: your idea didn't work sadly, you have to split the input into 2 lines instead of the popup coming up twice, also if you only do the 1st line the code crashes