Reading inputs in java

Posted by Gandalf StormCrow on Stack Overflow See other posts from Stack Overflow or by Gandalf StormCrow
Published on 2010-04-05T12:33:45Z Indexed on 2010/04/05 12:43 UTC
Read the original article Hit count: 509

Filed under:

Hello everyone I'm trying to improve my Java skills by solving some problems from ACM, now the thing is my sample input looks like this :

 3 100
 34 100
 75 250
 27 2147483647
 101 304
 101 303
 -1 -1

So at first I'm just trying to read them but its not working here is the java code:

import java.io.BufferedInputStream;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {
        Scanner stdin = new Scanner(new BufferedInputStream(System.in));
        while (stdin.hasNext()) {
            System.out.println(stdin.nextInt() + " and the next " + stdin.nextInt());
        }
    }
}

I'm trying to send these inputs as an argument, and not by reading them from file, here is how:

alt text

The program just spins(executes) but not printing anything. How can I fix this?

© Stack Overflow or respective owner

Related posts about java