
It is used to check if there is another line in the input of this scanner or not. It is used to check if the next token in this scanner's input can be interpreted as an int using the nextInt() method or not. It is used to check if the next token in this scanner's input can be interpreted as a Float using the nextFloat() method or not. It is used to check if the next token in this scanner's input can be interpreted as a BigDecimal using the nextByte() method or not. It is used to check if the next token in this scanner's input can be interpreted as a Byte using the nextBigDecimal() method or not. It is used to check if the next token in this scanner's input can be interpreted as a Boolean using the nextBoolean() method or not. It is used to check if the next token in this scanner's input can be interpreted as a BigDecimal using the nextBigDecimal() method or not. It returns true if this scanner has another token in its input. It is used to find the next occurrence of a pattern constructed from the specified string, ignoring delimiters. It is used to find a stream of match results that match the provided pattern string. It is used to get the Pattern which the Scanner class is currently using to match delimiters. The following are the list of Scanner methods: SN Scanner(ReadableByteChannel source, String charsetName) It constructs a new Scanner that produces values scanned from the specified channel. It constructs a new Scanner that produces values scanned from the specified string. It constructs a new Scanner that produces values scanned from the specified source. Scanner(InputStream source, String charsetName) It constructs a new Scanner that produces values scanned from the specified input stream. It constructs a new Scanner that produces values scanned from the specified file. Scanner in = new Scanner("Hello Javatpoint") To get a single character from the scanner, you can call next().charAt(0) method which returns a single character. The Java Scanner class provides nextXXX() methods to return the type of value such as nextInt(), nextByte(), nextShort(), next(), nextLine(), nextDouble(), nextFloat(), nextBoolean(), etc. The Java Scanner class extends Object class and implements Iterator and Closeable interfaces. By the help of Scanner in Java, we can get input from the user in primitive types such as int, long, double, byte, float, short, etc. It is the simplest way to get input in Java. The Java Scanner class is widely used to parse text for strings and primitive types using a regular expression. It provides many methods to read and parse various primitive values. The Java Scanner class breaks the input into tokens using a delimiter which is whitespace by default.


Java provides various ways to read input from the keyboard, the class is one of them.

Scanner class in Java is found in the java.util package.
