Campbell Ritchie wrote:A Scanner always takes input and doesn't seem ever to return null. But it has some peculiarities which are often not well documented. The nextLine method is a particular example. What does your book say nextLine does? I keep asking that and not getting answers.
I will look, but this is just me messing about - i can't remember which book I learnt about the scanner class from!
I shall blind you with science by telling you that nextLine and nextInt use different delimiters.
The problem you have is that you are calling nextSomething and following it with nextLine. You might not notice, but your method calls nextInt at the end and is then repeated, calling nextLine. That is equivalent to nextSomething followed by nextLine. You can see part of the explanation here.
because the method is called twice from main? or are you saying that the method itself calls nextLine(), nextInt(),
and then nextLine() again for some reason that (you're right) I've not noticed.
thanks for the link though, will start reading it now!
I believe the correct solution is to write yourself a utility class which uses a Scanner to read from the keyboard. You can find a way to deal with the problem with nextLine here. Of course, unless you are very experienced you won't see what a dreadful mistake I made in that post. You must read the whole thread.
clearly the mistake is you being a nuisance :P
will make sure i read all of it!
Nick