0% found this document useful (0 votes)
5 views2 pages

Scanner

The Scanner class in Java, located in the java.util package, is used for obtaining user input. To utilize it, an object of the Scanner class must be created, allowing access to various methods for reading different data types from the console. Available methods include nextBoolean(), nextByte(), nextDouble(), nextFloat(), nextInt(), nextLine(), nextLong(), and nextShort().

Uploaded by

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

Scanner

The Scanner class in Java, located in the java.util package, is used for obtaining user input. To utilize it, an object of the Scanner class must be created, allowing access to various methods for reading different data types from the console. Available methods include nextBoolean(), nextByte(), nextDouble(), nextFloat(), nextInt(), nextLine(), nextLong(), and nextShort().

Uploaded by

akashsable0571
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Java

Scanner:-
The Scanner class is used to get user input, and it is found in the java.util package.
To use the Scanner class, create an object of the class and use any of the available methods found in the Scanner class.

Steps:-
Create the Object of scanner Class, and then using the methods of scanner we can read the value from the console.
Following are the methods available in scanner class.

Method Description
nextBoolean() Reads a boolean value from the user
nextByte() Reads a byte value from the user
nextDouble() Reads a double value from the user
nextFloat() Reads a float value from the user
nextInt() Reads a int value from the user
nextLine() Reads a String value from the user
nextLong() Reads a long value from the user
nextShort() Reads a short value from the user

You might also like