{"id":1409,"date":"2022-03-03T19:33:29","date_gmt":"2022-03-03T19:33:29","guid":{"rendered":"https:\/\/mdr.foobrdigital.com\/?p=1409"},"modified":"2022-03-03T19:33:29","modified_gmt":"2022-03-03T19:33:29","slug":"program-to-read-integer-value-from-the-standard-input","status":"publish","type":"post","link":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/2022\/03\/03\/program-to-read-integer-value-from-the-standard-input\/","title":{"rendered":"Program to read integer value from the Standard Input"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Example: Program to read the number entered by user<\/h4>\n\n\n\n<p>We have imported the package\u00a0<code>java.util.Scanner<\/code>\u00a0to use the Scanner. In order to read the input provided by user, we first create the object of Scanner by passing\u00a0<code>System.in<\/code>\u00a0as parameter. Then we are using nextInt() method of Scanner class to read the integer. If you are new to Java and not familiar with the basics of java program then read the following topics of\u00a0Core Java:<br>\u2192\u00a0Writing your First Java Program<br>\u2192\u00a0How JVM works<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import java.util.Scanner;\n\npublic class Demo {\n\n    public static void main(String&#91;] args) {\n\n        \/* This reads the input provided by user\n         * using keyboard\n         *\/\n        Scanner scan = new Scanner(System.in);\n        System.out.print(\"Enter any number: \");\n\n        \/\/ This method reads the number provided using keyboard\n        int num = scan.nextInt();\n\n        \/\/ Closing Scanner after the use\n        scan.close();\n        \n        \/\/ Displaying the number \n        System.out.println(\"The number entered by user: \"+num);\n    }\n}<\/code><\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Enter any number: 101\nThe number entered by user: 101<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Example: Program to read the number entered by user We have imported the package\u00a0java.util.Scanner\u00a0to use the Scanner. In order to read the input provided by user, we first create the object of Scanner by passing\u00a0System.in\u00a0as parameter. Then we are using nextInt() method of Scanner class to read the integer. If you are new to Java [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[554],"tags":[],"_links":{"self":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/1409"}],"collection":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/comments?post=1409"}],"version-history":[{"count":0,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/1409\/revisions"}],"wp:attachment":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/media?parent=1409"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/categories?post=1409"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/tags?post=1409"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}