0% found this document useful (0 votes)
3 views1 page

Scanner Classnotes

The Scanner class in the java.util package is a utility for reading input from various sources, including the keyboard, files, and strings. It provides methods for reading different data types such as integers, doubles, booleans, and entire lines of text. Common methods include next(), nextLine(), nextInt(), nextDouble(), and close().

Uploaded by

alakaameen97
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Scanner Classnotes

The Scanner class in the java.util package is a utility for reading input from various sources, including the keyboard, files, and strings. It provides methods for reading different data types such as integers, doubles, booleans, and entire lines of text. Common methods include next(), nextLine(), nextInt(), nextDouble(), and close().

Uploaded by

alakaameen97
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

SCANNER CLASS

The scanner class is a utility class in the [Link] package. That allows programs to accept and process
easily. its most commonly used to take input from the key board

but it can also read from files, strings or other input sources, it can also help in reading and converting
data of various type without the need for complex parsing.

COMMONLY USED SCANNER METHOD

1. NEXT; this reads a single word until a space or new line.

2. NEXTLINE; this reads an entire line of text (including spaces) until the enter key is pressed

* NEXTlint; this reads an integer value

3. NEXT DOUBLE; this reads a floating point number

4. NEXT LONG; this reads a longer integer

5. NEXT BOOLEAN; this reads a boolean value (true/false)

6. HasNext; this returns true if another token available

7. HasNextln; this returns true if the next token can be read as an integer

8. HasNextDouble; this return true if the next can be read as a a double

9. HasNextLine; this checks if another line of text is available

10. CLOSE; this closes the scanner

You might also like