I have the following code
public static void main(String args[]){
Scanner scanner = new Scanner(System.in);
int noOfTestCases = scanner.nextInt();
String[] firstStringsList = new String[noOfTestCases];
String[] secondStringsList = new String[noOfTestCases];
for(int i=0;i<noOfTestCases;i++){
firstStringsList[i] = scanner.nextLine();
secondStringsList[i] = scanner.nextLine();
}
for(int i=0;i<noOfTestCases;i++){
System.out.println("First String : " + firstStringsList[i]);
System.out.println("Second String : " + secondStringsList[i]);
}
}
and the output goes as
1
asd
First String :
Second String : asd
i.e I first enter 1 which means I have 1 test case which involves getting two String inputs(per test case).
But I am able to enter only 1 String which is assigned to the secondStringsList[i]
. I am using Intellij IDEA
. Why is this happening? Workaround?