Scanner class
nextBoolean()
Reads a boolean value from the user
nextByte()
Reads a byte value from the user
nextDouble()
Reads a double value from the user Scanner myObj = new Scanner(System.in); // Numerical input int age = double salary = myObj.nextDouble();
nextFloat()
Reads a float value from the user
nextLong()
Reads a long value from the user
nextShort()
Reads a short value from the user
nextLine()
Scanner myObj = new Scanner(System.in); Reads a String value from the user // String input String name = myObj.nextLine();
nextInt()
Scanner myObj = new Scanner(System.in); Reads a int value from the user // Numerical input int age = myObj.nextInt();
How do you use Scanner?
Scanner myObj = new Scanner(System.in); create an object of the class and use any of the available methods found in the Scanner class documentation.
What does the Scanner class do?
The Scanner class is used to get user input, and it is found in the java.util package.