Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 I need help with java
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
mar5000k




PostPosted: Thu Sep 13, 2012 10:59 am   Post subject: 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?
Sponsor
Sponsor
Sponsor
sponsor
DemonWasp




PostPosted: Thu Sep 13, 2012 12:00 pm   Post subject: 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();
mar5000k




PostPosted: Thu Sep 13, 2012 3:10 pm   Post subject: RE:I need help with java

Thank you DemonWasp! You gave me some light.
wtd




PostPosted: Thu Sep 13, 2012 10:55 pm   Post subject: RE:I need help with java

Not to toot my own horn, but: Introduction to Java.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: