Hi there,
I am new to Java and have a question about user input.

In my book they use Keyboard.readInt() etc
A tutorial I watch does
Scanner input = new Scanner(system.in)
I also saw a few videos doing, well I don't remember exactly but something like...
I remember they imported io.* or somethig, and before the class body they wrote throws exception.
And they also had to use bufferedReader.

Is any of these ways the 'best' way?
Or perhaps one/some/all of these ways are outfated?
Or simply bad for some reason?

Whicj one should I use?

I'm watching tutorials with Scanner, so that is what I'm most comfortable with.

Alsi, I have seen some classes looking like
Class name extends b{}
What does that mean? That might be too advanced for me though as I am pretty new to Java.

Recommended Answers

All 3 Replies

The Scanner class is a very easy way to get user input. It has a lot of useful methods that can help you determine what will be read and to convert the input from String to different data types.
There are lots of different I/O classes for reading data. Each has a different use and purpose.

Do you have a link to the Java Tutorial? You should look through that for the answers to your basic java programming questions.

You will need to try different ones to see what best fits your purpose.
You will probably find one you like better than others and stick to that one until you REALLY need something else.

Is this user input from buttons and other GUI controls?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.