Scanner is a class in java.util package used for obtaining the input of the primitive types like int, double etc. and strings. Using Scanner class we can enter the data at run time.
The Java Scanner class breaks the input into tokens using a delimiter that is whitespace by default. It provides many methods to read and parse various primitive values. Java Scanner class is widely used to parse text for string and primitive types using a regular expression.
public class inputdata
public static void main(String args)
Scanner input = new Scanner(System.in);
System.out.println(“Enter the Name: “);
// String input
String name = input.nextLine();
System.out.println(“Name: is “+name);
Enter the Name: mili
Name is mili
To learn more in detail about Java at TCCI
Call us @ 9825618292
Visit us @ http://www.tccicomputercoaching.com