0
User input in java ?
Can anyone plz explain how do we take user input in java .I didnt quite understand the module ...
2 Respostas
+ 1
One of the easiest way for user input is to use a Scanner object.
Scanner scan = new Scanner(System.in);
//Reads from System.in
System.out.println("Enter a number");
int x = scan.nextInt();
//Scans the input of Integer type
scan.close();
//once finished close scanner
https://code.sololearn.com/czaZjwJ5fBz1/?ref=app
https://www.sololearn.com/learn/Java/2220/
+ 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.