Can users be asked to input anything using solo code playground?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can users be asked to input anything using solo code playground??

Java

7th Jun 2017, 7:03 PM
divine nnaemeka
divine nnaemeka - avatar
2 Answers
+ 8
You can take inputs, but you can't change the input message or output anything before the input prompt pops up. And the user will have to input everything in that one input prompt, values separated by line break. Example: https://code.sololearn.com/cxdPW83QP6Mm/?ref=app
7th Jun 2017, 7:27 PM
Tashi N
Tashi N - avatar
+ 4
Yes. The most common way is to use a Scanner. import java.util.Scanner; // top of program class Program{ public static void main(String args[]){ Scanner sc = new Scanner(System.in); // Creating scanner object // Using System.in inputStream String input = sc.nextLine(); // takes the whole line the user enters } } Scanners have many other methods too, you can find them all here: https://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html
7th Jun 2017, 7:26 PM
Rrestoring faith
Rrestoring faith - avatar