How to get input from user in Java

preview_player
Показать описание
Java User Input

To use the Scanner class, create an object of the class and use any of the available methods found in the Scanner class documentation. In our example, we will use the nextLine() method, which is used to read Strings:

Input Types

In the example above, we used the nextLine() method, which is used to read Strings. To read other types, look at the table below:-

Method Description
------------------------------ ---------------------------------------------
nextBoolean() Reads a boolean value
from the user.

nextByte() Reads a byte value from
the user.

nextDouble() Reads a double value
from the user.

nextFloat() Reads a float value from
the user.

nextInt() Reads a int value from
the user.

nextLine() Reads a String value
from the user.

nextLong() Reads a long value from
the user.

nextShort() Reads a short value from
the user.

#BackCoding
#java
#programming
#shorts
Рекомендации по теме