aspose file tools*
The moose likes Beginning Java and the fly likes Best way to get user input Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Best way to get user input" Watch "Best way to get user input" New topic
Author

Best way to get user input

Karl Collins
Greenhorn

Joined: Nov 22, 2011
Posts: 21
Hi,

I have been learning java in school. Were only learning the extreme basics so please bear with me

Were using a file ( I think its called a library ) to grab user input an then display it on screen in our java programs.

I want to learn how to avoid using the program and have been looking up tutorials on YouTube.
I seen the scanner but its confusing as to how I would use it in a program such as this. Also is there a better option than scanner?

What I want to do is ask what age are you?

then age will equal the users input.

Karl Collins
Greenhorn

Joined: Nov 22, 2011
Posts: 21
Ah I have since figured all of this out!

It took a while but I'm beginning to grasp the use of the Scanner!
Satyen Singh
Greenhorn

Joined: Oct 05, 2011
Posts: 21

Hey Karl,

Don't think that Scanner is confusing or hard understand.
Remember Java's 1st Feature is that Java is "Simple" so, nothing is hard in java.
Scanner is very easy.
I will explain you how to use it and why .......

Now, If you want to read user input age from the console.
following is the code snippet in java using scanner.

Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4347
    
    2

you also might want to read about JOptionPane. it will display a separate dialog window to get user input.


SCJP
Visit my download page
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39884
    
  28
Satyen Singh wrote:. . . . Remember Java's 1st Feature is that Java is "Simple" so, nothing is hard in java. . . .
You have misunderstood the intention behind “simple”. It means that a programmer can remember all the rules, without having to look them up. I am not at all convinced they have achieved that intention, least of all since the introduction of generics in Java5.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Best way to get user input