java - Reading integers from a line -
i'm trying read 2 integers on same line.
scanner a=new scanner(system.in); x=a.nextint(); y=a.nextint();
now, if input
3 4
3 4
x = 3 , y = 3. tried using a.usedelimiter("\\s") doesn't work.
there must error elsewhere in code. works fine me.
import java.util.scanner; class main { public static void main(string[] args) { scanner = new scanner(system.in); int x = a.nextint(); int y = a.nextint(); system.out.println("x = " + x + ", y = " + y); } }
input:
3 4 3 4
output:
x = 3, y = 4
see working online: ideone
Comments
Post a Comment