How to take user input in java using Scanner

As we discussed in previous post, that JOptionPane is one of many ways to take input from user in java. Scanner can also be used to take user input. It is a text scanner which can parse primitive types and strings using regular expressions.

Here is the code snippet to use Scanner to take input from user:

Output of the above code fragment would be:
What is your name?
Name: David

Hope you find the information presented here useful. Please leave your footprints in the comments section below for any queries or suggestions.

  1. I like the valuable information you supply for your
    articles. I’llbookmark your weblog and take
    a look at again right here regularly. I am fairly sure I’ll learn many new stuff right
    right here! Good luck for the next!

    My siite :: diabetes

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">