File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

user input values

 
tushar parab
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to take user input values in java as we do it in c by using scanf and in C++ using cin >>
 
Vidyakar Sharma
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi tushar,
use java.util.Scanner class for taking user inputs or
use Reader class with some buffering capability.
First one is easy for you as you are learning right now.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47313
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can also use Swing classes, eg the input dialogue method of JOptionPane.
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or you can use the java.io.Console class as of java 6
 
Anupam Jain
Ranch Hand
Posts: 61
Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only interesting thing is....

All the above three input methods would give you String values only... (or so do I think.)

 
Vidyakar Sharma
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Anupam,
You are forgetting that Scanner has a number of methods like nextInt and nextLong.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47313
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remember that Console only works when you start the application from the command line with the java command.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic