{"id":13369,"date":"2020-11-18T03:47:30","date_gmt":"2020-11-18T11:47:30","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=13369"},"modified":"2023-12-01T04:04:09","modified_gmt":"2023-12-01T12:04:09","slug":"java-input","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/java-input\/","title":{"rendered":"Java User Input and Scanner Class: A Step-By-Step Guide"},"content":{"rendered":"\n<p><em>The Scanner class is used to read Java user input. Java Scanner is built into the java.util package, so no external libraries are needed to use it. Scanner reads text from standard input. This text is returned to the main program so it can be stored or otherwise manipulated.<\/em><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>Understanding how to get user input in Java is a crucial skill. For instance, say you are building an app with a sign-in form. You will need to handle user input to collect the login credentials for the user.\n\n<\/p>\n\n\n\n<p>In Java, you can use the <em>Scanner<\/em> class to receive user input that you can then process in your program. This tutorial will discuss, using a few examples, how to utilize the Java Scanner class to receive user input.\n\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Java Scanner Class<\/h2>\n\n\n\n<p>The Java Scanner class is used to collect user input. Scanner is part of the java.util package, so it can be imported without downloading any external libraries. Scanner reads text from standard input and returns it to a program.\n\n<\/p>\n\n\n\n<p>In order to work with the Scanner class, you must first import it into your code. There are two ways you can do this:\n\n<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>If you only need to work with the <em>java.util.Scanner<\/em> class, you can import the Scanner class directly.<\/li><li>If you are working with other modules in the <em>java.util<\/em> library, you may want to import the full library.<\/li><\/ol>\n\n\n\n<p>The following is the code for each of the above methods:\n\n<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import java.util.Scanner;\nimport java.util.*;<\/pre><\/div>\n\n\n\n<p>The first line of code imports the Scanner class. The second line of code imports all the packages within the java.util library, including Scanner.<\/p>\n\n\n\n<p>It\u2019s worth noting that there are other ways to receive user input data in Java. You can use Java\u2019s BufferedReader, InputStreamReader, DataInputStream, and Console classes.<\/p>\n\n\n\n<p>However, the Scanner class is the most popular method of collecting user input in Java. So, we will be focusing on that class in this article.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Java User Input Syntax<\/h2>\n\n\n\n<p>You can collect user input using the Scanner class. The Scanner class reads text that a user inserts into the console and sends that text back to a program. Scanner is the primary method of collecting Java user input.<\/p>\n\n\n\n<p>After you import the Java Scanner class, you can start to use it to collect user input. Here is the syntax for the Java Scanner class:\n<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Scanner input = new Scanner(System.in);\nint number = input.nextInt();\n<\/pre><\/div>\n\n\n\n<p>In this example, we created a variable called <code>input<\/code> that collects the next value the user inputs into the console. Then we created a variable called <code>number<\/code> that collects the value the user submits to the console.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Java User Input Example<\/h2>\n\n\n\n<p>For instance, suppose we are building an application for a local computer store that keeps track of their inventory.<\/p>\n\n\n\n<p>The manager asked us to create a simple program that she can use to add items to the shop\u2019s inventory list. The manager wants to be able to input two values: the name of the item and its quantity.<\/p>\n\n\n\n<p>Here\u2019s the code we would use to create this program:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import java.util.Scanner;\n\nclass Main {\n\tpublic static void main(String[] args) {\n\t\tScanner input = new Scanner(System.in);\n\n\t\tSystem.out.print(&quot;Product name: &quot;);\n\t\tString product_name = input.next();\n\t\tSystem.out.print(&quot;Value entered: &quot; + product_name);\n\n\t\tSystem.out.print(&quot;Quantity: &quot;);\n\t\tint quantity = input.nextInt();\n\t\tSystem.out.print(&quot;Value entered: &quot; + quantity);\n\t}\n}\n<\/pre><\/div>\n\n\n\n<p>The first input we accept the name of the item. This will be a string because the item names are text-based and use a variety of characters. In the code below, we define this string with the code: <em>String product_name<\/em>.\n\n<\/p>\n\n\n\n<p>The next input is the quantity of the item. This will be a number. In the code below, we define this number with the code: <em>int quantity<\/em>, where <em>int<\/em> stands for integer.\n\n<\/p>\n\n\n\n<p>When we run our code and insert a few example values, the program returns the following response:<\/p>\n\n\n\n<p><code>Product name: 15-inch MacBook Pro 2019<\/code><\/p>\n\n\n\n<p><code>Value entered: 15-inch MacBook Pro 2019<\/code><\/p>\n\n\n\n<p><code>Quantity: 7<\/code><\/p>\n\n\n\n<p><code>Value entered: 7<\/code><\/p>\n\n\n\n<p>As you can see, our program collected the user\u2019s input. It then returned to the console the value the user entered. This allows us to verify that our program is working.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How our Scanner Java Program Works<\/h3>\n\n\n\n<p>Let\u2019s break down our code step-by-step.<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>We import the Scanner library into our code so that we can receive user input.<\/li><li>We declare a class called Main that stores the code for our program.<\/li><li>We initialize the Scanner class using <em>Scanner input = new Scanner(System.in);<\/em> The input <a href=\"https:\/\/careerkarma.com\/blog\/java-variables\/\">Java variable<\/a> stores our initialized scanner.<\/li><li>We print out \u201cProduct name: \u201d to the console and ask the user to submit a product name using <em>input.next();<\/em>.<\/li><li>We print out to the console the product name the user submitted.<\/li><li>We print out <em>Quantity:<\/em> to the console and prompt the user to submit the quantity of the product in stock using <em>input.nextInt();<\/em>.<\/li><li>We print out the value of the <em>quantity<\/em> variable to the console.<\/li><\/ol>\n\n\n\n<p>Notice that we used different code to collect numbers and strings. When we collected the product name, we used <em>input.next();<\/em>, and when we collected the product quantity, we used <em>input.nextInt();<\/em>.\n\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Java Scanner: Input Types<\/h2>\n\n\n\n<p>In our above example, we collected two types of data from the user: a string and an integer. As mentioned, we had to use different code to collect these types of data.\n\n<\/p>\n\n\n\n<p>Different types of data, like strings and integers, are collected using separate methods. So, to collect a boolean, you\u2019ll use different code than you would to collect a float.\n\n<\/p>\n\n\n\n<p>Here is a table showing all the methods used to collect user input in Java using the Scanner class:<\/p>\n\n\n\n<table class=\"wp-block-table course-info-table\"><tbody><tr><td><strong>Method<\/strong><\/td><td><strong>Type of Value the Method Collects<\/strong><\/td><\/tr><tr><td>nextBoolean()<\/td><td>boolean<\/td><\/tr><tr><td>nextByte()<\/td><td>byte<\/td><\/tr><tr><td>nextDouble()<\/td><td>double<\/td><\/tr><tr><td>nextFloat()<\/td><td>float<\/td><\/tr><tr><td>nextInt()<\/td><td>int<\/td><\/tr><tr><td>nextLine()<\/td><td>String<\/td><\/tr><tr><td>nextLong()<\/td><td>long<\/td><\/tr><tr><td>nextShort()<\/td><td>short<\/td><\/tr><\/tbody><\/table>\n\n\n\n<p>If you insert the wrong input type, your program will raise an InputMismatchException. For example, if you try to insert a double into a field that collects Booleans, your program will raise an exception.&nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Collecting a Boolean Value<\/h3>\n\n\n\n<p>Let\u2019s go back to the computer store. Suppose we wanted to update our first program and allow our computer store manager to input whether the product is on display or held in the stockroom.<\/p>\n\n\n\n<p>To do so, we want to collect a new value called <em>on_display<\/em> that will store input as a Boolean because it can have only two values: true or false.\n\n<\/p>\n\n\n\n<p>Here\u2019s the code we could use to collect this data:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import java.util.Scanner;\n\nclass Main {\n\tpublic static void main(String[] args) {\n\t\tScanner input = new Scanner(System.in);\n\n\t\tSystem.out.print(&quot;Product name: &quot;);\n\t\tString product_name = input.next();\n\t\tSystem.out.print(&quot;Value entered: &quot; + product_name);\n\n\t\tSystem.out.print(&quot;Quantity: &quot;);\n\t\tint quantity = input.nextInt();\n\t\tSystem.out.print(&quot;Value entered: &quot; + quantity);\n\nSystem.out.print(&quot;On display: &quot;);\n\t\tboolean on_display = input.nextBoolean();\n\t\tSystem.out.print(&quot;Value entered: &quot; + on_display);\n\t}\n}\n<\/pre><\/div>\n\n\n\n<p>When we run our code and insert a few example values, the program returns the following response:<\/p>\n\n\n\n<p><code>Product name: 15-inch MacBook Pro 2019<\/code><\/p>\n\n\n\n<p><code>Value entered: 15-inch MacBook Pro 2019<\/code><\/p>\n\n\n\n<p><code>Quantity: 7<\/code><\/p>\n\n\n\n<p><code>Value entered: 7<\/code><\/p>\n\n\n\n<p><code>On display: true<\/code><\/p>\n\n\n\n<p><code>Value entered: true<\/code><\/p>\n\n\n\n<p>Our program works in the same way as our example above. However, this time we collect an additional value from the user: whether the product they inserted into the program is on display. We use the <em>nextBoolean() <\/em>method to collect this value from the user. Then we print that value to the console.\n\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>You can use Java\u2019s Scanner class to collect input from a user. The Scanner class is capable of collecting a variety of data types from users, including short values, Strings, booleans, and others.\n\n<\/p>\n\n\n\n<p>In this tutorial, using a few examples, we explored how to use the Java Scanner class to collect user input. In addition, we discussed the different data types offered by the Scanner class that we can use to collect user input.<\/p>\n\n\n\n<p>To learn more about coding in Java, read our <a href=\"https:\/\/careerkarma.com\/blog\/how-to-learn-java\/\">How to Code in Java guide<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"The Scanner class is used to read Java user input. Java Scanner is built into the java.util package, so no external libraries are needed to use it. Scanner reads text from standard input. This text is returned to the main program so it can be stored or otherwise manipulated. Understanding how to get user input&hellip;","protected":false},"author":240,"featured_media":13370,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[17289],"tags":[],"class_list":{"0":"post-13369","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-java"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"Java","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":null,"is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.0 (Yoast SEO v27.0) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Java User Input and Scanner Class: A Step-By-Step Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"The Java \u201cScanner\u201d class to collects input from a user. On Career Karma, learn how to utilize Java\u2019s Scanner class to receive user input.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/java-input\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java User Input and Scanner Class: A Step-By-Step Guide\" \/>\n<meta property=\"og:description\" content=\"The Java \u201cScanner\u201d class to collects input from a user. On Career Karma, learn how to utilize Java\u2019s Scanner class to receive user input.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/java-input\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2020-11-18T11:47:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T12:04:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/person-in-front-of-laptop-on-brown-wooden-table-2115217.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"800\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"James Gallagher\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"James Gallagher\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/careerkarma.com\/blog\/java-input\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/java-input\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"Java User Input and Scanner Class: A Step-By-Step Guide\",\"datePublished\":\"2020-11-18T11:47:30+00:00\",\"dateModified\":\"2023-12-01T12:04:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/java-input\/\"},\"wordCount\":1176,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/java-input\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/person-in-front-of-laptop-on-brown-wooden-table-2115217.jpg\",\"articleSection\":[\"Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/careerkarma.com\/blog\/java-input\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/careerkarma.com\/blog\/java-input\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/java-input\/\",\"name\":\"Java User Input and Scanner Class: A Step-By-Step Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/java-input\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/java-input\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/person-in-front-of-laptop-on-brown-wooden-table-2115217.jpg\",\"datePublished\":\"2020-11-18T11:47:30+00:00\",\"dateModified\":\"2023-12-01T12:04:09+00:00\",\"author\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"The Java \u201cScanner\u201d class to collects input from a user. On Career Karma, learn how to utilize Java\u2019s Scanner class to receive user input.\",\"breadcrumb\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/java-input\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/careerkarma.com\/blog\/java-input\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/java-input\/#primaryimage\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/person-in-front-of-laptop-on-brown-wooden-table-2115217.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/person-in-front-of-laptop-on-brown-wooden-table-2115217.jpg\",\"width\":1200,\"height\":800},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/careerkarma.com\/blog\/java-input\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\/\/careerkarma.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\/\/careerkarma.com\/blog\/java\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Java User Input and Scanner Class: A Step-By-Step Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\",\"url\":\"https:\/\/careerkarma.com\/blog\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/careerkarma.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\",\"name\":\"James Gallagher\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"caption\":\"James Gallagher\"},\"description\":\"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.\",\"url\":\"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Java User Input and Scanner Class: A Step-By-Step Guide | Career Karma","description":"The Java \u201cScanner\u201d class to collects input from a user. On Career Karma, learn how to utilize Java\u2019s Scanner class to receive user input.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/careerkarma.com\/blog\/java-input\/","og_locale":"en_US","og_type":"article","og_title":"Java User Input and Scanner Class: A Step-By-Step Guide","og_description":"The Java \u201cScanner\u201d class to collects input from a user. On Career Karma, learn how to utilize Java\u2019s Scanner class to receive user input.","og_url":"https:\/\/careerkarma.com\/blog\/java-input\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-11-18T11:47:30+00:00","article_modified_time":"2023-12-01T12:04:09+00:00","og_image":[{"width":1200,"height":800,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/person-in-front-of-laptop-on-brown-wooden-table-2115217.jpg","type":"image\/jpeg"}],"author":"James Gallagher","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"James Gallagher","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/java-input\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/java-input\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"Java User Input and Scanner Class: A Step-By-Step Guide","datePublished":"2020-11-18T11:47:30+00:00","dateModified":"2023-12-01T12:04:09+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/java-input\/"},"wordCount":1176,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/java-input\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/person-in-front-of-laptop-on-brown-wooden-table-2115217.jpg","articleSection":["Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/java-input\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/java-input\/","url":"https:\/\/careerkarma.com\/blog\/java-input\/","name":"Java User Input and Scanner Class: A Step-By-Step Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/java-input\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/java-input\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/person-in-front-of-laptop-on-brown-wooden-table-2115217.jpg","datePublished":"2020-11-18T11:47:30+00:00","dateModified":"2023-12-01T12:04:09+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"The Java \u201cScanner\u201d class to collects input from a user. On Career Karma, learn how to utilize Java\u2019s Scanner class to receive user input.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/java-input\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/java-input\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/java-input\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/person-in-front-of-laptop-on-brown-wooden-table-2115217.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/person-in-front-of-laptop-on-brown-wooden-table-2115217.jpg","width":1200,"height":800},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/java-input\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/careerkarma.com\/blog\/java\/"},{"@type":"ListItem","position":3,"name":"Java User Input and Scanner Class: A Step-By-Step Guide"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94","name":"James Gallagher","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","caption":"James Gallagher"},"description":"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.","url":"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/13369","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/240"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=13369"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/13369\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/13370"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=13369"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=13369"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=13369"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}