Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

How to get User Input?  RSS feed

Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);

Posts: 9521
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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:
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!