+ 1

How to use Scanner

When i import java.util.scanner The want to get the input from the user, its always saying the local variable is never closed. I did it this way Scanner x = new Scanner(System.in); System.out.print(x.nextLine());

17th Oct 2019, 3:49 PM
Thon Tor Chol
Thon Tor Chol - avatar
4 ответов
+ 6
Apparently some versions of Java will warn you if your scanner is left unclosed. To fix this, just close your scanner once you no longer have any need for it. Scanner x = new Scanner(System.in); System.out.print(x.nextLine()); x.close(); https://www.tutorialspoint.com/java/util/scanner_close.htm
17th Oct 2019, 3:59 PM
Hatsy Rei
Hatsy Rei - avatar
+ 2
Didn't know that, thanks Hatsy Rei
17th Oct 2019, 4:33 PM
HNNX 🐿
HNNX 🐿 - avatar
+ 1
Thanks hatsy Rei. It works
17th Oct 2019, 4:35 PM
Thon Tor Chol
Thon Tor Chol - avatar
0
Oh that is useful thx!
12th Nov 2024, 6:12 AM
Odessa
Odessa - avatar