Scanner class

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

DYNAMIC READ

DYNAMIC READ :
The process of reading a data from the user during execution of a program is
known as dynamic read.

STEPS TO ACHIEVE DYNAMIC READ :


Step 1 : Import Scanner class from java.util package.
import java.util.Scanner ;
Step 2 : Create an object for the child class.
Scanner input = new Scanner(System.in);
Step 3 : Call the method of Scanner class to read the data from the user
input.methodName();
METHODS IN A SCANNER CLASS :

TYPE OF DATA METHOD SIGNATURE RETURN TYPE


byte nextByte() byte
short nextShort() short
int nextInt() int
long nextLong() long
float nextFloat() float
double nextDouble() double
boolean nextBoolean() boolean
char next().charAt(0) char
String (single word) next() String
String(Multi word) nextLine() String
OUTPUT

You might also like