What is the method that enables the user to get data from the user like in forms, or in a program that requires a user to input data.
Well, those are two different things. Michael already posted the answer for a text field in a GUI (like in Windows Forms).
For a command line program, you can read a line from stdin and parse it to extract a number
from it. If you are using Java 5, there's a simpler way. You can use the new class java.util.Scanner.
You wrap a scanner around anything that can be a suitable source of chars, such as the input stream System.in. Here's an example:
This is a lot simpler than before! There are nextFOO() methods for each primitive type and for
object types that make sense, like
String. This isn't raw I/O - the input isn't watched char
by cahr, so the user has to type return before any of it is seen.
Anyway, if you are using Java 5, you will enjoy this.
Cheers,
Peter