User input in java ? | Sololearn: Learn to code for FREE!

User input in java ?

Can anyone plz explain how do we take user input in java .I didnt quite understand the module ...

31st Mar 2018, 4:36 AM
Amitesh Shrey
Amitesh Shrey - avatar
2 Respostas
+ 1
One of the easiest way for user input is to use a Scanner object. Scanner scan = new Scanner(; //Reads from System.out.println("Enter a number"); int x = scan.nextInt(); //Scans the input of Integer type scan.close(); //once finished close scanner
31st Mar 2018, 4:45 AM
Nilesh - avatar
+ 1
If you have just started learning java, I'll recommend you to take a look at how to take input using command line arguments. They are easy to understand. You'll understand scanner and buffered reader classes better once you will complete input/output streams in java.
31st Mar 2018, 10:51 AM
Nikhil Sharma
Nikhil Sharma - avatar