Tag: resource leak

扫描仪永远不会关闭

我正在开发一款游戏,我的扫描仪遇到了一些问题。 我的资源泄漏扫描仪从未关闭。 但我以为我的扫描仪在没有关闭它之前就已经工作了。 但现在不是。 有人可以帮帮我吗? import java.util.Scanner; public class Main { public static final boolean CHEAT = true; public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int amountOfPlayers; do { System.out.print(“Select the amount of players (1/2): “); while (!scanner.hasNextInt()) { System.out.println(“That’s not a number!”); scanner.next(); // this is important! } amountOfPlayers = […]