Computer Science, asked by shilapatel64265, 1 month ago

Please explain me the use of scanner class in java program with an example.​

Answers

Answered by parthu2011
0

Answer:

used to read input of different primitive data types like int, float, strings, etc.

The Java Scanner class breaks the input into tokens using a delimiter which is whitespace by default. It provides many methods to read and parse various primitive values. The Java Scanner class is widely used to parse text for strings and primitive types using a regular expression.

Explanation:

Scanner is a class in java. util package used for obtaining the input of the primitive types like int, double, etc. and strings. It is the easiest way to read input in a Java program, though not very efficient if you want an input method for scenarios where time is a constraint like in competitive programming.

Similar questions