title: How can I handle new line character using java-util-scanner in this situation?
body: <p>I have a simple homework assignment, I'm making a simple UI (not GUI) and I'm using scanner for input. </p>
  
  <p>I want to read 3 strings (Name, address, social security number)</p>
  
  <p>If the user however does not insert anything simply presses enter, my code breaks. Instead of the 3 strings I need, I get more strings and they miss match.</p>
  
  <pre><code>Scanner input = new Scanner(System.in);
  if (input.hasNext()) {
      name = input.nextLine(); 
  } 
  Scanner input = new Scanner(System.in);
  if (input.hasNext()) {
      address = input.nextLine(); 
  } 
  Scanner input = new Scanner(System.in);
  if (input.hasNext()) {
      ssnumb = input.nextLine(); 
  } 
  </code></pre>
  
  <p>So if user presses enter, creates a new line character, the input spills. How can I either avoid this or eliminate empty lines ?</p>
  
  <p><strong>Example:</strong></p>
  
  <p><em>enter</em></p>
  
  <p>Nick</p>
  
  <p>Mars</p>
  
  <p><em>some number</em></p>
  
  <p><strong>I would have:</strong></p>
  
  <p><code>Name:</code></p>
  
  <p><code>Address:</code> Nick</p>
  
  <p><code>Social Security Number:</code> Mars</p>