This seems be a common question (asked multiple times) yet I'm not able to find an explanation for this behaviour. Following code works in one compiler but throws Exception in thread "main" java.util.NoSuchElementException
in another compiler
Scanner s = new Scanner(System.in);
System.out.println("Enter name: ");
String name = s.next();
System.out.println("Name is " + name);
Tested on https://www.compilejava.net/ and https://www.codechef.com/ide it throws exception. However, on some compilers it works fine. Is there any reason for this behaviour (like change in JDK or something)?