Java: try(Scanner scan = new Scanner(System.in) { } causing an exception
问题 Using try(Scanner scan = new Scanner(System.in)) { } is causing Exception in thread "main" java.util.NoSuchElementException When I try to debug it says that Variable information not available, source compiled without -g option. and shows the below code public Scanner(InputStream source) { this(new InputStreamReader(source), WHITESPACE_PATTERN); } One of my methods that uses this line: protected String loginName(){ String username; String password; try (Scanner scan = new Scanner(System.in)) {