title: how to remove input buffer from java
body: <p>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</p>
  
  <pre><code>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&lt;n;i++)
  {
      arr[i] = input.nextLine();
  }
  </code></pre>
  
  <p>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</p>