+ 1
I can't understand the usage of Scanner class in java
please help
3 Réponses
+ 2
https://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html
"A Scanner breaks its input into tokens using a delimiter pattern, which by default matches whitespace. The resulting tokens may then be converted into values of different types using the various next methods."
Then given an input, it is broken up and the separation points are those identified by a regular expression (default is whitespace). the tokens thus obtained are returned to you one at a time in the sequence in which they occur, possibly converted, by means of the various next methods. The input of a new Scanner object is passed as an argument to the constructor and can go from a String, to a File, a Readable interfacce object, up to an InputStream as in the case of the System.in object which provides the input data stream from the standard input (trivially the keyboard)
+ 1
To take user input
0
Pariket has given explanation. here are some example,
a chatbot
a game like number guessing
assign variable just when you run code.
also, sololearn java compiler ask input only when you run code