Hi,
I am using JDK 1.6 and creating a simple program in which I need to accept an integer value from the keyboard. I am using the following code to do it
int a = (int) System.in.read();
It works but when I print the value it is not the same as inserted.
What's the problem ......... ?
Please Reply!!!
Loading
Deepak VermaPosted Jul 19, 2011, 6:09 AM
The line of code, you are using is just convert the input char or first char of string to its ASCII value.
You may use this code to accept input from keyboard
BufferedReader BRd = new BufferedReader(new InputStreamReader(System.in));
String temp = BRd.readLine();
Integer.parseInt(temp);
Note: Don't forget to import System.io.*
LegolasPosted Jul 19, 2011, 7:58 AM
Jaganathan BantheswaranPosted Jul 19, 2011, 6:11 AM
Please post the entire code.