Hi, it is kind of a beginner's question... I'm trying to read user's input from keyboard. The user types in:
a1 a2 a3
b1 b2 b3
c1 c2 c3
...
in which each line has three integers separated by a space. Every three integers are on the same line.
Scanner in = new Scanner(System.in)
do{
if(in.nextLine().equals("\n"))
break;
int a= in.nextInt();
int b=in.nextInt();
int d=in.nextInt();
adList[a][b]=d;
}while(true);
I thought when I hit enter to switch to a new line and hit enter again, it should stop reading integers then and gets out of the loop. But it never knows when the input ends.
How can I achieve this by reading in the control character '\n' then end the loop?
Thanks