I'm trying to input a certain number of strings but the last input gets a new line as input automatically. I need to remove the input buffer plz help
Scanner input = new Scanner(System.in);
int n = input.nextInt(); //n is my input number
String[] arr = new String[n];
int i,j;
for(i=0;i<n;i++)
{
arr[i] = input.nextLine();
}
If I enter n=5 as input and when i print the array my last input string goes missing and is replaced by a new line character