java scanner class methods

Java Scanner class

To make coding less, the Designers introduced java.util.Scanner (Scanner is not from java.io package) in Java 5. Earlier to Java Scanner class, keyboard input was taken using DataInputStream and BufferedReader, both requiring extra code of parsing the user input. Java Scanner avoids parsing. Example on Java Scanner taking Keyboard input…