Computer Science, asked by 6200797376, 11 months ago

name a few constructors provided by the scanner class​

Answers

Answered by riya4865
4

Explanation:

The Scanner class is a class in java.util package, which allows a user to read values of various types.

The Scanner looks for tokens in the input. A token is a series of characters that ends with whitespace. A whitespace character can be a blank, a tab character, a carriage return, or the end of the file.

For example, if we read a line that has a series of numbers separated by blanks, the scanner will take each number as a separate token.

Constructors

Scanner class has several constructors. Among them, the following are particularly useful.

Constructor Description

Scanner(File source) Constructs a new scanner that produces values scanned from the specified file. If the source file is not found, a FileNotFoundException is thrown. Since it is a cheked exception, it must be caught or forwarded by putting the phrase “throws FileNotFoundException” in the method header.

Scanner(InputStream source) Constructs a new Scanner that produces values scanned from the specified input stream.

Scanner(String source) Constructs a new scanner that produces values scanned from the specified string

Hope it helps you

Similar questions