In this article,Getting input from Keyboard is explained in detail with examples.
"Scanner" is a class, using which, we can accept input from standard input device i.e.Keyboard.
"Scanner" is a class, using which, we can accept input from standard input device i.e.Keyboard.
This class is available in java.util package.Such package need to be imported in a java program.
Ex
import java.util.*; or
import java.util.Scanner;
To use this class,we create object of this class.
Ex
Scanner sc=new Scanner(System.in); //System.in defines standard input device i.e. Keyboard.
for getting the input from keyboard the statement should be in the format shown below
String ss=sc.next();
String ss=sc.nextline(); (From topic Getting input from Keyboard)