English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

System.out.println () function is used to print data. Please tell me the function / program to input data in java from user. Not using applets.

2006-10-25 18:49:08 · 4 answers · asked by shivani k 1 in Computers & Internet Programming & Design

4 answers

You can access input data by using the
System.in.read()
it returns an int value corresponding to the ascii,
and one more restriction is there you can read only one char at a time.
you can also use the BufferedReader, for that you need to import the java.io library.

good luck.

2006-10-25 19:21:32 · answer #1 · answered by Anand 3 · 3 0

there is no direct function available like system.out.println()

U have to redirect the standard input to a buffer. so u can use the following code
String s = new String();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
s=br.readLine();

this will read a line for u. if u wnat to convert it into an integer then u have to use
int i=Interget.parseInt(s);

for float and other datatypes also we have the classes Float, Boolean etc

2006-10-26 02:15:36 · answer #2 · answered by smartsuman2k1 2 · 1 1

input function of java

init()

2006-10-26 01:58:52 · answer #3 · answered by Mostaque 2 · 1 0

u can use Scanner class in util package.

2006-10-26 06:12:29 · answer #4 · answered by Franzi 1 · 0 0

fedest.com, questions and answers