View Single Post
Old Apr 11th, 2005, 6:18 PM   #1
357mag
Hobbyist Programmer
 
Join Date: Mar 2005
Posts: 148
Rep Power: 4 357mag is on a distinguished road
It doesn't look like there is an easy way

In C++ you can output to the screen using cout and get user input by using cin. It's very easy and quick. For example this program prompts the user to enter an integer and then displays it back:

int main( )
{
int number;

cout << "Enter an integer";
cin >> number;
cout << "You entered " << number << endl;

return 0;
}

Simple.

Now I'm looking for a way to do the same thing in Java. I know how to output a message. Just type System.out.println("You entered ");

But how do you get input? I'm not talking about using dialog boxes(GUI components). A book I have shows how to do that. But I'm talking about how to get input from the console. From what I've turned up so far it looks too complicated for me to understand. After all I'm at the beginning and only done some C++ console programming.

If you can show some code in order to do this that would be great.
357mag is offline   Reply With Quote