+ 4
How the command line "import java.util.Scanner" affects my hole code?
I don't really understand this "Scanner" method and its function. What is the purpose of create this command line ?
5 Antworten
+ 24
It doesn't make any changes in your code until you declare a Scanner. The main use of Scanner is to get user input. If you are unable to understand Scanner, try to analyze other java codes made by other users so that you can get idea about what it is.
https://code.sololearn.com/c4D5bso3Tsip/?ref=app
https://code.sololearn.com/c4OEP6tooV9I/?ref=app
https://code.sololearn.com/cnnABvV231bA/?ref=app
+ 6
You can import it and then make a user input, it doesn't affect your code however.
+ 6
in laymans terms: the scanner is not in all programs, and you did not create the code. So you have to import it from the java library (add the code) to your program in order to use the code.
You could just create your own scanner object, then you wouldn't need to import it. Good luck with that though.
+ 3
when it required to accept input from user then use Scanner class. import it and use its methods. scanner is use only for accept input from user
+ 1
the command line will enable the user to input data directly using the keyboard or import them from the file ....so importing will not have any other effects to the code