Search This Blog

Thursday, December 31, 2009

read input from console

Java How to read input from console
Public class read
import java.util.*;

/**
* @author Yogesh Patel
*/
public class read
{
public static void main(String[] args)
{
//System.in Because it will take input from system in device
Scanner scann= new Scanner(System.in);

// get first input
System.out.print("Enter your name please ");
String name = in.nextLine();

// get second input
System.out.print("what is Your Dob ? ");
int age = in.nextInt();

// display output on
System.out.println("Hello, " + name + ". Your Dob is " + (age + 1));
}
}

No comments: