Scanner in Java
Scanner is used in JAVA to accept the values from the user through the Standard I/O devices.
Below is a basic program to demonstrate the use of scanner :
OUTPUT :
Below is a basic program to demonstrate the use of scanner :
import java.util.Scanner;
public class scan {
public static void main(String[] args)
{
Scanner s=new Scanner(System.in);
System.out.println("Enter any string");
String a=s.nextLine();
System.out.println("String is :"+a);
}
}
OUTPUT :
Enter any string
codeground
String is :codeground
codeground
String is :codeground
Comments
Post a Comment