title: next() vs nextLine() in JAVA
body: <p>I was trying to take input for the number of names to be stored in an array from user and then using that i was taking names from the user ,first i tried to take names from the user using <code>next()</code> method and all the things were fine but when i tried to take input using <code>nextLine()</code> method the output was as shown below </p>
  
  <pre><code>package learningJava;
  import java.util.Scanner;
  
  public class practice
  {
      public static void main(String[] args)
      {
          int n;
          Scanner obj = new Scanner(System.in);
          System.out.println("Enter the number of names you are gonna enter");
          n = obj.nextInt();
  
          String names[] = new String[n];
          for(int i=0;i&lt;n;i++)
          {
              System.out.println("Enter the name of friend "+(i+1));
              names[i]=obj.nextLine();
          }
          obj.close();
          System.out.println("Names of your friends are");
          for(int i=0;i&lt;names.length;i++)
          {
              System.out.println(names[i]);
          }
      }
  }
  </code></pre>
  
  <p>Output for the <code>nextLine()</code> method </p>
  
  <pre><code>Enter the number of names you are gonna enter
  5
  Enter the name of friend 1
  Enter the name of friend 2
  </code></pre>
  
  <p>It is not prompting me to enter the name of friend 1 and directly skipping it and coming to the friend 2 line.
  I am beginner in Java , i know the basic difference in  next and <code>nextLine()</code> that <code>next()</code> doesn't take input after a space but <code>nextLine()</code> takes complete input , So what is happening here ??</p>