NoSuchElementException in simple User Input loop Java 8 [on hold]

Clash Royale CLAN TAG#URR8PPPNoSuchElementException in simple User Input loop Java 8 [on hold]
I've looked around here a lot and haven't found an answer to my problem. I get the exception at "return in13.nextInt()". I've tried a lot of different ways of doing this "play again" thing, that's why right now I have an "int" value for it. I'd be very happy if someone showed me the best way to add this feature to my text game!
Edit: This got reported for being "off-topic" because I didn't say what want the code to do, apparently. I want
getPlayAgain() to run after game() runs until "user" inputs an integer other than 1.
(I'm a beginner at Java)
private static Scanner in13;
public static void main(String args) {
do
{
game();
}
while(getPlayAgain() == 1);
in13.close();
}
public static int getPlayAgain() {
in13 = new Scanner(System.in);
System.out.println("Would you like to play again?");
return in13.nextInt();
}
This question appears to be off-topic. The users who voted to close gave this specific reason:
@Lino How do I do that? I’m new here, sorry.
– Dygyty
1 hour ago
It seems that somewhere in the
game method, you're closing in13 or System.in. Since you're closing in13 at end of main you should initialize it at start of main, not inside getPlayAgain.– Andreas
1 hour ago
game
in13
System.in
in13
main
main
getPlayAgain
@Andreas No, I’ve checked that...
– Dygyty
1 hour ago
How are you running the code? Using
java from command-line? If so, the only reason for NoSuchElementException is that you closed System.in, directly or indirectly.– Andreas
1 hour ago
java
NoSuchElementException
System.in
Post the stacktrace please
– Lino
1 hour ago