V
V
Vitaly2017-02-03 19:10:11
Java
Vitaly, 2017-02-03 19:10:11

What is the best input method to use in Java?

What is the best input method to use in Java?

BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));

or
Scanner in = new Scanner(System.in);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Kornachev, 2017-02-03
@vivalazz

In the first case, reading is faster. If the user enters everything manually, then you will not notice the acceleration.
Further convenience just for you. The first option allows you to read character by character / line by line / a certain length. The second option has a bunch of methods for reading a specific data type. For example, you ask the user to enter a number and make a call to in.nextInt().

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question