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 :

 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

Comments

Popular posts from this blog

Write a java program for a cricket player The program should accept the details from user (max 10): Player code, name, runs, innings- played and number of times not out.

Write a MultiThreading program in java using Runnable interface to draw temple flag on an applet container.

Create a smiling and crying face alternet using Threading Mechenism