import java.util.Scanner; public class Main{ public static void main (String[] args) { int s = 0; Scanner in = new Scanner(System.in); while (in.hasNextDouble()) { double x = in.nextDouble(); s += 1; } System.out.println(s); }}
1 25 38 abc
Standard output is empty
Exception in thread "main" java.util.InputMismatchException at java.util.Scanner.throwFor(Scanner.java:864) at java.util.Scanner.next(Scanner.java:1485) at java.util.Scanner.nextDouble(Scanner.java:2413) at Main.main(Main.java:12)
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!