Using Scanner Class:
Scanner class is used to get input from the user, to use this class, you will have to import java.util.scanner package.
Get Input from User program in Java
Common functions to get input
Method |
Description |
next() |
to get string without space from the user |
nextLine() |
to get string with spaces from the user |
nextInt() |
to get integer value from the user |
nextFloat() |
to get float value from the user |
nextByte() |
to get byte value from the user |
In this program we will read Name, Gender, Age and Float and then print all inputted values.
Output