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 ...

3/31/2018 4:36:05 AM

Amitesh Shrey

2 Answers

New Answer


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


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.