Reading Inputs in Java - help

Posted by peiska on Stack Overflow See other posts from Stack Overflow or by peiska
Published on 2010-06-03T12:17:05Z Indexed on 2010/06/03 12:24 UTC
Read the original article Hit count: 165

Filed under:
|
|

I am having a problem reading inputs, can anyone help me.

Each line of the input have to Integers: X e Y separated by a space.

12 1
12 3
23 4
9 3

I am using this code in java but is not working, its only reading the first line can anyone help me?

    String []f; 
    String line;
    Scanner in=new Scanner(System.in);

    while((line=in.nextLine())!=null){
        f=line.split(" ");

        int X,Y;
        N=Integer.parseInt(f[0]);
        K=Integer.parseInt(f[1]);

        if(X<=40 && Y<=40)
          metohod(X,Y); 


        linha=in.nextLine();

    }
}

© Stack Overflow or respective owner

Related posts about java

Related posts about input