
-----------------------------------
mar5000k
Thu Sep 13, 2012 10:59 am

I need help with java
-----------------------------------
I am teaching my self Java programming and still doing introduction and orientation.
My problem is, How do I prompt for user input?? The book I am reading says that TextIO.getlnint() is not a built in function. That, it should be writen or created for each program I write, however I have no idea where to start from. Any help please?

-----------------------------------
DemonWasp
Thu Sep 13, 2012 12:00 pm

RE:I need help with java
-----------------------------------
Input is usually by InputStreams (there are several different kinds). The console input stream is known as System.in .

To make your life easier, you usually want to use the Scanner class (available since Java 1.5): Scanner in = new Scanner ( System.in ); . Now, the Scanner instance in will read from standard input.

For example, you might want to ask someone their name:
[code]
Scanner in = new Scanner ( System.in );
System.out.println ( "Please enter your name" );
String name = in.nextLine();
[/code]

-----------------------------------
mar5000k
Thu Sep 13, 2012 3:10 pm

RE:I need help with java
-----------------------------------
Thank you DemonWasp! You gave me some light.

-----------------------------------
wtd
Thu Sep 13, 2012 10:55 pm

RE:I need help with java
-----------------------------------
Not to toot my own horn, but: [url=http://wiki.compsci.ca/index.php?title=Introduction_To_Java]Introduction to Java.
