The following program is expected to accept 'T' number of input strings in the String array, and display them. But it accepts and displays one string less then expected. Why is it so? The program is:
import java.util.Scanner;
public class JavaApplication1
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
String s[] = new String[50];
for (int i = 0; i < T; i++)
{
s[i] = sc.nextLine();
}
for (int i = 0; i < T; i++)
{
System.out.println(s[i]);
}
}
}