Inside the parenthesis, the <codeclass="language-java">Scanner</code> binds to the System input which is by default the console
The new varible <codeclass="language-java">input</code> now has the ability to obtain input from the console. To do so, use any of the following methods
<tableclass="tg">
<tr>
<thclass="tg-yw4l">
Method
</th>
<thclass="tg-yw4l">
What it Returns
</th>
</tr>
<tr>
<tdclass="tg-yw4l">
next()
</td>
<tdclass="tg-yw4l">
The next space seperated string from the console
</td>
</tr>
<tr>
<tdclass="tg-yw4l">
nextInt()
</td>
<tdclass="tg-yw4l">
An integer if it exists from the console
</td>
</tr>
<tr>
<tdclass="tg-yw4l">
nextDouble()
</td>
<tdclass="tg-yw4l">
A double if it exists from the console
</td>
</tr>
<tr>
<tdclass="tg-yw4l">
nextFloat()
</td>
<tdclass="tg-yw4l">
A float if it exists from the console
</td>
</tr>
<tr>
<tdclass="tg-yw4l">
nextLine()
</td>
<tdclass="tg-yw4l">
A string up to the next newline character from the console
</td>
</tr>
<tr>
<tdclass="tg-yw4l">
hasNext()
</td>
<tdclass="tg-yw4l">
Returns true if there is another token
</td>
</tr>
<tr>
<tdclass="tg-yw4l">
close()
</td>
<tdclass="tg-yw4l">
Unbinds the Scanner from the console
</td>
</tr>
</table>
Here is an example program where we get the user’s first name