Getting a Input from a user


Pre-requisite:

1.Java installed.

Step 1:Write a Java code to get the input from a user and and display back again.

File:getin.java

import java.io.*;
class getin
{
public static void main(String ar[])
{
String name=””;
System.out.println(”Enter your data to display”);
BufferedReader datain=new BufferedReader(new InputStreamReader(System.in));
try
{
name=datain.readLine();
System.out.println(”The value you have entered is ” +name);
}
catch(IOException e)
{
System.out.println(”Error Occured”);
}
}
}

Sample Output:
Enter your data to display
Nice Time
The value you have entered is Nice Time

Feel free to share your comments.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s