title: How to interrupt while loop if user enters something
body: <p>I need to be able to interrupt a while loop only when a user enters something. Otherwise the loop should continue.</p>
  
  <p>I tried using <code>if (scanner.nextLine())</code> however this will cause the loop to wait until something is entered before moving on.</p>
  
  <p>How can I keep the loop continuing until something is entered?</p>
  
  <pre><code>while (true) {
      if (scanner.nextLine()) {
      // statements
      }
  
      // standard loop statements
  }
  </code></pre>