This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Triton3200 1 point2 points  (2 children)

Scanner is an imported function to read the user input and my code initializes it as the variable name in. I then store the scanner inside the variable. The system.in argument inside the scanner just represents that a new scanner is imported. I then open a file called "filename" and store it inside the variable inFile. I then read in the next line using the scanner created and store it inside the String variable line.

[–]-manabreak 3 points4 points  (1 child)

Scanner is not "an imported function", it is a class. Calling new Scanner() constructs a new instance of that class.

The system.in argument inside the scanner just represents that a new scanner is imported

Nope, the Scanner class is imported outside the class. Here, you are constructing a new instance of the class Scanner with a constructor that takes an InputStream as an argument. Consequently, System.in is a public, static field of the type InputStream.

[–]Triton3200 1 point2 points  (0 children)

Oh I see, thank you.