title: Understanding Scanner's nextLine(), next(), and nextInt() methods
body: <p>I am trying to understand how these three methods work. Here's how I understood them: </p>
  
  <ul>
  <li><code>nextLine()</code> reads the remainder of the current line even if it is empty.   </li>
  <li><code>nextInt()</code> reads an integer but does not read the escape sequence "\n".  </li>
  <li><code>next()</code> reads the current line but does not read the "\n". </li>
  </ul>
  
  <p>Suppose I have the following code: </p>
  
  <pre><code>import java.util.Scanner;
  
  public class Welcome2
  {
      public static void main(String[] args)
      {
          Scanner keyboard = new Scanner(System.in);
          System.out.println("Next enter two words:");
  
          int n; 
          String s1, s2; 
  
          n = keyboard.nextInt(); 
          s1 = keyboard.next(); 
          s2 =  keyboard.nextLine(); 
          System.out.println(" n is " + n + " s1 is " + s1 + " s2 is " + s2); 
      }
  }
  </code></pre>
  
  <p>If my input is : </p>
  
  <pre><code>2 
  
  Hi 
  
  Hello 
  </code></pre>
  
  <p>Then I get the following output on screen: </p>
  
  <pre><code>n is 2 
  s1 is hi 
  s2 is  
  </code></pre>
  
  <p>Why would <code>s1</code> have a value of "HI"? </p>
  
  <p>Does this mean that the method <code>next()</code> reads the next line even though the escape character for the first line has not been read by <code>nextInt()</code>? </p>