import java.util.Scanner;
public class TestOnly {
public static void main(String[] args) throws Exception {
Scanner sc=new Scanner(System.in);
int iteration=sc.nextInt();
int i=0;
for(i=1;i<=iteration;i++)
{
System.out.println("Hello World!");
String input=sc.nextLine();
System.out.println(input);
}
}
}
If I give input 1 for iteration variable then the for loop runs for one time. At that time I should be able to take a String input.
But String input can be taken from the second loop. Please explain the reason if you know. Thank you.