I actually found some threads on this subject the other day but I can't find them again now when I do a search. I'm needing a more thorough understanding of writing statements to make a Java program get basic input from a user. For example, if my output statement is:
System.out.println("Please enter your telephone number");
How do I get the user's data when he inputs it? From what I gather so far, methods of reading input vary according to the situation and need. One thing (I think) may work is using the statement:
Scanner sc = new Scanner(System.in);
to instantiate a Scanner class, then nameing it sc, and wrap it around stdin. Then the statement:
Scanner sc = sc.nextInt(); reads the telephone number the user inputs using his keyboard. Since an integer number will be entered, the type is int.
Actually Scanner is the more uptodate way of reading input, but was only introduced in Java 5. If you are happy to restrict use of your program to Java 5 or above JVMs then use Scanner, otherwise use BufferredReader.