I need to take input in the form of- Given 'n' number of boxes and each of these boxes may contain any number of distinct integers, So first user enters n,then for each value of i from 1 to n,I need to enter values till enter is pressed. I don't know how to do this, Eg-
5
1 2 3 4 5 6 7 8 9
1 2
1
4 5 6
3 4 5 6 7
I have tried this-
String str;
for(int i=0;i<n;i++)
{
while(true)
{
str=scanner.next();
if(str.isEmpty())
break;
int val=Integer.parseInt(str);
}
}
Also tried str.equals("\n") and str.equals(""), But nothing is working. Somebody please help me out.Thanks.