HP18 lucky number - showing error has NoSuchElementFound

admincheckout

#1

Hi
My code works perfectly in IDE and here it is showing NoSuchElementFound error. How could this be?


#2

I’m also getting the same error :frowning:


#3

NoSuchElementException generally occurs in Java when Scanner is used in a wrong way.

The most common mistake is when Scanner is re-initialized in a function after every function call.

One possible solution is to create a global Scanner or creating it in Main and passing it as argument to the functions.


#4

tried this also but not working