Creating a single Scanner object in main() and passing the object to other methods is considered good practice because _____
Expert-verified answer
0 (0 оценки)
0
Martebi 6 months ago
Светило науки - 5616 ответа - 0 помощи

Creating a single Scanner object in main() and passing the object to other methods is considered good practice because to it help to make subsequent reads faster and when a method needs to read user input.

Why do we pass system in Scanner?

Scanner class is known to be one that allows the user to take input from console. It helps one to know the java compiler that system input will be given via console(keyboard).

When a method is said to needs to read user input, a good thing to do is to form a single Scanner object in main() and then one has to move that Scanner object to the method.

Learn more about Scanner from

https://brainacademy.pro/question/24937533

Still have questions?