title: Proper way to use Scanner with multiple functions?
body: <p>I have a console application with a <code>main</code> method and some methods that I call from <code>main</code>. There, I want to ask the user for some input, for which I use the <code>Scanner</code> class.</p>
  
  <p>Here's my problem:</p>
  
  <p>I find there is no way to use <code>Scanner</code> when reading inputs from outside <code>main</code> without random exceptions or unexpected behaviour. I have tried two approaches:</p>
  
  <ol>
  <li>Having a <code>Scanner</code> global variable in the class containing <code>main</code>. Then
  I use this same <code>Scanner</code> in all functions in that same class.</li>
  <li>In every function I need to ask for input, I declare a new <code>Scanner</code>
  variable, use it, and <code>close</code> it before exiting the function.</li>
  </ol>
  
  <p>1. makes <code>Scanner</code> try to read twice. I mean, I have a <code>sc.readLine</code> in a function and, when I exit that function, I have another <code>sc.readLine</code> in <code>main</code>. I input once and the two <code>readLine</code> lines get executed, the second one reading an empty <code>String</code>.</p>
  
  <p>2. throws <code>Exception</code> (<em>base class Exception</em>) when I call any <code>sc.readLine</code> for a second time during the execution of the program.</p>
  
  <p>I have also noticed that any other method other than <code>readLine</code> is going to read various items on the same line. For example, line <code>"10 20 30 40"</code> would execute 4 <code>sc.nextInt</code> calls.</p>
  
  <p><strong>TL;DR:</strong> how do you use <code>Scanner</code> in a console application?</p>