This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes How to get User Input? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to get User Input?" Watch "How to get User Input?" New topic

How to get User Input?

Niyas Ahmed Sheikh
Ranch Hand

Joined: Jun 15, 2005
Posts: 129
I want to get the input and based upon it, it should run; How to do in Java. I got the below coding in net. It's not compiling. What's wrong with this?

class Greeting
public static void main (String args [])
//read in the name of the user
String name = Input.readString("What is your name?");

System.out.println("Hello " + name);

Joe Ess

Joined: Oct 29, 2001
Posts: 8836

Originally posted by Niyas Ahmed Sheikh:
What's wrong with this?

Well, first and foremost, it's in the wrong language. If you want to use Java, you should become familiar with the
Java API Documentation and the Java Tutorial. They should answer many of your questions about how things are done.
That said, in Java 1.5 we can use java.util.Scanner to read a line in from the input stream:

"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
wood burning stoves
subject: How to get User Input?
Similar Threads
Try and catch Help!
coin flip assignment help
How to display objects in array list?
how to run RMI with Eclips
java redirection