| Author |
Using a scanner parameter
|
Mark Captain
Ranch Hand
Joined: Nov 01, 2011
Posts: 30
|
|
Hi, I need to use a method with a Scanner as a parameter that is
What I have to do is call method in my main method to open on a .txt file and i cannot find a way for my code to work when i try to put the file to open inside like so
i am getting the error "The method loadBusStops(Scanner) in the type BusManager is not applicable for the arguments (String"
I understand why it is saying it is a string and that it my file to open needs to by of the "Scanner type". But how would I do this?
|
 |
Jeff Verdegan
Bartender
Joined: Jan 03, 2004
Posts: 3143
|
|
This:
says that when you call loadBusStops, you will pass it a Scanner. It seems that you know that, given that your subject is "Using a scanner parameter".
Does this:
Look like you're passing a Scanner to that method? That is, do you think "bus-stops.txt" is a Scanner?
You need to do one of two things:
1) Pass a Scanner when you call loadBusStops(), as the method declaration says you will. This means you have to construct the Scanner with an appropriate File, Readable, or InputStream first, and then pass it to loadBusStops().
OR
2) Change loadBusStops() to take a String parameter. Then, inside the method, you construct the Scanner with an appropriate File, Readable, or InputStream for the file whose name you received.
|
 |
 |
|
|
subject: Using a scanner parameter
|
|
|