-2

java.util.NoSuchElementException problem... I used two scanners

scanbud()

and

scabudrad()
  • 3
    Add the ***complete*** stacktrace as ***text***. – Guy Jul 25 '17 at 12:01
  • 4
    You give us 225 lines of code .. with tons of useless, lines, please edit and remove some – azro Jul 25 '17 at 12:02
  • 3
    [How to create a Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) – matoni Jul 25 '17 at 12:03
  • 1
    dont close the scanner, try again, share the lessons learned – ΦXocę 웃 Пepeúpa ツ Jul 25 '17 at 12:04
  • Possible duplicate of [Exception in thread "main" java.util.NoSuchElementException](https://stackoverflow.com/questions/15398703/exception-in-thread-main-java-util-nosuchelementexception) – Tom Jul 25 '17 at 12:57
  • Please don't add the solution to the answer itself. Instead, post it as answer or mark one of the existing answers as accepted (like you already did). – FelixSFD Jul 30 '17 at 07:00

1 Answers1

1

The reason is here:

scanbudRad.close();     

you are using multiple instances of the scanner, _BUT as soon as you closes a scanner, that instance close under the hood too the input stream which is shared between all other remaining instances... after that, trying to read /get something from an scanner object with a InputStream closed throws the exception.

ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97
  • so should i put only 1 scanner through out? I read a page saying the close and open scanner with each logical block of code – MrHyde Gaming Jul 25 '17 at 12:04