| Author |
how to accept i/p's from user
|
amal shah
Ranch Hand
Joined: May 05, 2006
Posts: 92
|
|
how to accept i/p's from user in a command prompt? when we want to print data to standard o/p we use system.out.print(data) ..but how do we accept data from user and store it in a variable /*system.in()...*/ is it? or is something to do with Handler class i am beginner pls help! Thank's amal
|
 |
Stephen Foy
Ranch Hand
Joined: Oct 17, 2005
Posts: 143
|
|
I presume you mean by "ips" as inputs, not a users actual IP address. You can get input from a user by using the "Scanner" class.
|
Stephen Foy - Microsoft Application Development Consultant
|
 |
Ellie Barnes
Greenhorn
Joined: Nov 20, 2005
Posts: 5
|
|
If you are indeed looking for command line input, you could also do it this way: You would need to provide some exception handling to go with this too, enclose your code in a try.......catch block. Event handling which you mention is usually used to get input from a GUI (e.g. a user clicks a button), whereas this kind of system prompt input is not event driven (maybe it can be?) Hope that's helpful  [ June 03, 2006: Message edited by: Ellie Barnes ]
|
 |
amal shah
Ranch Hand
Joined: May 05, 2006
Posts: 92
|
|
|
thank's ellie that helped...stephen the scanner class don't seem to appear in java doc 1.4..well how to go about with this scanner class
|
 |
marc weber
Sheriff
Joined: Aug 31, 2004
Posts: 11343
|
|
Originally posted by amal shah: thank's ellie that helped...stephen the scanner class don't seem to appear in java doc 1.4..well how to go about with this scanner class
The java.util.Scanner was new with Java 1.5. So if you're using 1.4 or earlier, you should use the approach outlined by Ellie. Or you can upgrade to Java 5.0.
|
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
|
 |
Charles Lyons
Author
Ranch Hand
Joined: Mar 27, 2003
Posts: 836
|
|
Or indeed look forward to the new java.io.Console class in Java SE 6!
|
Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 / Amazon Amazon UK )
|
 |
Edwin Dalorzo
Ranch Hand
Joined: Dec 31, 2004
Posts: 961
|
|
|
Could use Jakarta Commons CLI, also.
|
 |
 |
|
|
subject: how to accept i/p's from user
|
|
|