I noticed that there are more than a few ways of creating user input in a command line program.
I simply don’t know which to choose.
First I was thinking of using an input scanner but then I’m just following the pseudocode of program which includes import java.io.*; tag and nothing more.
Which input method should I use from import java.io.*; which gives me the ability to not only read String but also double and char values without much trouble?
I was googling ways of doing the input but each site uses a different method, which would you recommend?
I would generally recommend using a
Scannerjust because it makes everything so easy. If you want to use something fromjava.io, you could use aBufferedReaderin conjunction with anInputStreamReader. Something like this:Well you get the point. You might have to do some parsing to obtain integers / doubles (using
Integer.parseInt(someString)/Double.parseDouble(someString)) from the user’s input.