Title: Scanner Java Example - Examples Java Code Geeks - 2026
Open Graph Title: Scanner Java Example - Examples Java Code Geeks - 2026
Description: Check out our detailed Scanner Java Example! We will also see how to use the Java Scanner class to read a Java input form the console.
Open Graph Description: Check out our detailed Scanner Java Example! We will also see how to use the Java Scanner class to read a Java input form the console.
Mail addresses
support@javacodegeeks.com
Opengraph URL: https://examples.javacodegeeks.com/java-util-scanner-scanner-java-example/
Generator: WordPress 6.9.4
Domain: examples.javacodegeeks.com
{"@context":"https://schema.org","@graph":[{"@type":"Article","@id":"https://examples.javacodegeeks.com/java-util-scanner-scanner-java-example/#article","isPartOf":{"@id":"https://examples.javacodegeeks.com/java-util-scanner-scanner-java-example/"},"author":{"name":"Armando Flores","@id":"https://examples.javacodegeeks.com/#/schema/person/edd8d967774c2c27aac159acda5ca9fe"},"headline":"java.util.Scanner – Scanner Java Example (with video)","datePublished":"2014-07-09T08:00:32+00:00","dateModified":"2022-07-06T11:24:40+00:00","mainEntityOfPage":{"@id":"https://examples.javacodegeeks.com/java-util-scanner-scanner-java-example/"},"wordCount":2029,"commentCount":2,"publisher":{"@id":"https://examples.javacodegeeks.com/#organization"},"image":{"@id":"https://examples.javacodegeeks.com/java-util-scanner-scanner-java-example/#primaryimage"},"thumbnailUrl":"https://examples.javacodegeeks.com/wp-content/uploads/2012/12/java-logo.jpg","articleSection":["Scanner"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https://examples.javacodegeeks.com/java-util-scanner-scanner-java-example/#respond"]}]},{"@type":"WebPage","@id":"https://examples.javacodegeeks.com/java-util-scanner-scanner-java-example/","url":"https://examples.javacodegeeks.com/java-util-scanner-scanner-java-example/","name":"Scanner Java Example - Examples Java Code Geeks - 2026","isPartOf":{"@id":"https://examples.javacodegeeks.com/#website"},"primaryImageOfPage":{"@id":"https://examples.javacodegeeks.com/java-util-scanner-scanner-java-example/#primaryimage"},"image":{"@id":"https://examples.javacodegeeks.com/java-util-scanner-scanner-java-example/#primaryimage"},"thumbnailUrl":"https://examples.javacodegeeks.com/wp-content/uploads/2012/12/java-logo.jpg","datePublished":"2014-07-09T08:00:32+00:00","dateModified":"2022-07-06T11:24:40+00:00","description":"Check out our detailed Scanner Java Example! We will also see how to use the Java Scanner class to read a Java input form the console.","breadcrumb":{"@id":"https://examples.javacodegeeks.com/java-util-scanner-scanner-java-example/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https://examples.javacodegeeks.com/java-util-scanner-scanner-java-example/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https://examples.javacodegeeks.com/java-util-scanner-scanner-java-example/#primaryimage","url":"https://examples.javacodegeeks.com/wp-content/uploads/2012/12/java-logo.jpg","contentUrl":"https://examples.javacodegeeks.com/wp-content/uploads/2012/12/java-logo.jpg","width":150,"height":150,"caption":"Bipartite Graph"},{"@type":"BreadcrumbList","@id":"https://examples.javacodegeeks.com/java-util-scanner-scanner-java-example/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://examples.javacodegeeks.com/"},{"@type":"ListItem","position":2,"name":"Java Development","item":"https://examples.javacodegeeks.com/category/java-development/"},{"@type":"ListItem","position":3,"name":"Core Java","item":"https://examples.javacodegeeks.com/category/java-development/core-java/"},{"@type":"ListItem","position":4,"name":"util","item":"https://examples.javacodegeeks.com/category/java-development/core-java/util/"},{"@type":"ListItem","position":5,"name":"Scanner","item":"https://examples.javacodegeeks.com/category/java-development/core-java/util/scanner/"},{"@type":"ListItem","position":6,"name":"java.util.Scanner – Scanner Java Example (with video)"}]},{"@type":"WebSite","@id":"https://examples.javacodegeeks.com/#website","url":"https://examples.javacodegeeks.com/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https://examples.javacodegeeks.com/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://examples.javacodegeeks.com/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https://examples.javacodegeeks.com/#organization","name":"Exelixis Media P.C.","url":"https://examples.javacodegeeks.com/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https://examples.javacodegeeks.com/#/schema/logo/image/","url":"https://examples.javacodegeeks.com/wp-content/uploads/2022/06/exelixis-logo.png","contentUrl":"https://examples.javacodegeeks.com/wp-content/uploads/2022/06/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https://examples.javacodegeeks.com/#/schema/logo/image/"},"sameAs":["https://www.facebook.com/javacodegeeks","https://x.com/javacodegeeks"]},{"@type":"Person","@id":"https://examples.javacodegeeks.com/#/schema/person/edd8d967774c2c27aac159acda5ca9fe","name":"Armando Flores","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https://examples.javacodegeeks.com/#/schema/person/image/","url":"https://examples.javacodegeeks.com/wp-content/uploads/2014/05/Armando-Flores-96x96.jpg","contentUrl":"https://examples.javacodegeeks.com/wp-content/uploads/2014/05/Armando-Flores-96x96.jpg","caption":"Armando Flores"},"description":"Armando graduated from from Electronics Engineer in the The Public University Of Puebla (BUAP). He also has a Masters degree in Computer Sciences from CINVESTAV. He has been using the Java language for Web Development for over a decade. He has been involved in a large number of projects focused on \"ad-hoc\" Web Application based on Java EE and Spring Framework.","sameAs":["http://www.javacodegeeks.com/"],"url":"https://examples.javacodegeeks.com/author/armando-flores/"}]}
{"@context":"http:\/\/schema.org","@type":"BreadcrumbList","@id":"#Breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"item":{"name":"Home","@id":"https:\/\/examples.javacodegeeks.com\/"}},{"@type":"ListItem","position":2,"item":{"name":"Java Development","@id":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/"}},{"@type":"ListItem","position":3,"item":{"name":"Core Java","@id":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/"}},{"@type":"ListItem","position":4,"item":{"name":"util","@id":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/util\/"}},{"@type":"ListItem","position":5,"item":{"name":"Scanner","@id":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/util\/scanner\/"}}]}
{"@context":"http:\/\/schema.org","@type":"Article","dateCreated":"2014-07-09T11:00:32+03:00","datePublished":"2014-07-09T11:00:32+03:00","dateModified":"2022-07-06T14:24:40+03:00","headline":"java.util.Scanner – Scanner Java Example (with video)","name":"java.util.Scanner – Scanner Java Example (with video)","keywords":[],"url":"https:\/\/examples.javacodegeeks.com\/java-util-scanner-scanner-java-example\/","description":"In this example, we will show the range of functionality provided by the java.util.Scanner - Scanner Java class. We will also see how to use the Java Scanner class to read a Java input form the consol","copyrightYear":"2014","articleSection":"Scanner","articleBody":"\nIn this example, we will show the range of functionality provided by the java.util.Scanner - Scanner Java class. We will also see how to use the Java Scanner class to read a Java input form the console. A simple text scanner which can parse primitive types and strings using regular expressions.\n\n\n\nYou can also check this tutorial in the following video:\n\n\n\nScanner Java Example - Video\n\n\n\n1. Introduction\n\n\n\nA Scanner breaks its input into tokens using a delimiter pattern, which by default matches whitespace.\n\n\n\nThe resulting tokens may then be converted into values of different types using the various next methods.\n\n\n\nFor example, this code allows a user to read a number from System.in:\n\n\n\n\n\n\n\n\n\n1\n2\n\n\n\nScanner sc = new Scanner(System.in);\nint i = sc.nextInt();\n\n\n\n\n\n\n\n\n\n\nThe scanner can also use delimiters other than whitespace. This example reads several items in from a string:\n\n\n\n\n\n\n\n\n\n1\n2\n3\n4\n5\n6\n7\n\n\n\nString input = \"1 fish 2 fish red fish blue fish\";\nScanner s = new Scanner(input).useDelimiter(\"\\\\s*fish\\\\s*\");\nSystem.out.println(s.nextInt());\nSystem.out.println(s.nextInt());\nSystem.out.println(s.next());\nSystem.out.println(s.next());\ns.close();\n\n\n\n\n\n\n\n\n\n\nThe following code shows you how you can use the Java Scanner class to read a Java input form the console. To start, you create a Scanner object passing System.in (which is the keyboard) as a parameter to the Constructor. Like the System.out object, the System.in object is created by Java automatically. Because of that, you can use this object with a Scanner object whenever you want to get a console input.\n\n\n\nOnce you've created a Scanner object, you can use the next methods to read data from the console. The method you use depends on the type of data you need to read. To read string data, for example, you use the next method. To read integer data, you use the nextInt method. To read double data, you use the the nextDouble method. And to read all of the data on a line, you use the nextLine method. When one of the methods of the Scanner class is run, the application waits for the user to enter data with the keyboard. To complete the entry, the user presses the Enter key.\n\n\n\nSince the Scanner class is in the java.util package, you'll want to include an import statement whenever you use this class.\n\n\n\n2. Scanner Constructors\n\n\n\n Here is a list of the Constructors in the Java scanner Class. \n\n\n\nConstructorDescription1.Scanner(File source)Constructs a new Scanner that produces values scanned from the specified file.2.Scanner(File source, String charsetName)Constructs a new Scanner that produces values scanned from the specified file.3.Scanner(InputStream source)Constructs a new Scanner that produces values scanned from the specified Java input stream.4.Scanner(InputStream source, String charsetName)Constructs a new Scanner that produces values scanned from the specified Java input stream.5.Scanner(Path source)Constructs a new Scanner that produces values scanned from the specified file.6.Scanner(Path source, String charsetName)Constructs a new Scanner that produces values scanned from the specified file.7.Scanner(Readable source)Constructs a new Scanner that produces values scanned from the specified source.8.Scanner(ReadableByteChannel source)Constructs a new Scanner that produces values scanned from the specified channel.9.Scanner(ReadableByteChannel source, String charsetName)Constructs a new Scanner that produces values scanned from the specified channel.10.Scanner(String source)Constructs a new Scanner that produces values scanned from the specified string.\n\n\n\n\n3. Scanner Methods\n\n\n\nHere is a list of the Methods in the Java scanner class.\n\n\n\nReturn TypeMethod NameDescription1.voidclose()Closes this scanner.2.Patterndelimiter()Returns the Pattern this Scanner is currently using to match delimiters.3.StringfindInLine(String pattern)Attempts to find the next occurrence of a pattern constructed from the specified string, ignoring delimiters.4.StringfindInLine(Pattern pattern)Attempts to find the next occurrence of the specified pattern ignoring delimiters.5.StringfindWithinHorizon(Pattern pattern, int horizon)Attempts to find the next occurrence of the specified pattern.6.StringfindWithinHorizon(String pattern, int horizon)Attempts to find the next occurrence of a pattern constructed from the specified string, ignoring delimiters.7.booleanhasNext()Returns true if this scanner has another token in its input.8.booleanhasNext(Pattern pattern)Returns true if the next complete token matches the specified pattern.9.booleanhasNext(String pattern)Returns true if the next token matches the pattern constructed from the specified string.10.booleanhasNextBigDecimal()Returns true if the next token in this scanner's Java input can be interpreted as a BigDecimal using the nextBigDecimal() method.11.booleanhasNextBigInteger()Returns true if the next token in this scanner's input can be interpreted as a BigInteger in the default radix using the nextBigInteger() method.12.booleanhasNextBigInteger(int radix)Returns true if the next token in this scanner's input can be interpreted as a BigInteger in the specified radix using the nextBigInteger() method.13.booleanhasNextBoolean()Returns true if the next token in this scanner's input can be interpreted as a boolean value using a case insensitive pattern created from the string \"true|false\".14.booleanhasNextByte()Returns true if the next token in this scanner's input can be interpreted as a byte value in the default radix using the nextByte() method.15.booleanhasNextByte(int radix)Returns true if the next token in this scanner's input can be interpreted as a byte value in the specified radix using the nextByte() method.16.booleanhasNextDouble()Returns true if the next token in this scanner's input can be interpreted as a double value using the nextDouble() method.17.booleanhasNextFloat()Returns true if the next token in this scanner's input can be interpreted as a float value using the nextFloat() method.18.booleanhasNextInt()Returns true if the next token in this scanner's input can be interpreted as an int value in the default radix using the nextInt() method.19.booleanhasNextInt(int radix)Returns true if the next token in this scanner's input can be interpreted as an int value in the specified radix using the nextInt() method.20.booleanhasNextLine()Returns true if there is another line in the input of this scanner.21.booleanhasNextLong()Returns true if the next token in this scanner's input can be interpreted as a long value in the default radix using the nextLong() method.22.booleanhasNextLong(int radix)Returns true if the next token in this scanner's input can be interpreted as a long value in the specified radix using the nextLong() method.23.booleanhasNextShort()Returns true if the next token in this scanner's input can be interpreted as a short value in the default radix using the nextShort() method.24.booleanhasNextShort(int radix)Returns true if the next token in this scanner's input can be interpreted as a short value in the specified radix using the nextShort() method.25.IOExceptionioException()Returns the IOException last thrown by this Scanner's underlying Readable.26.Localelocale()Returns this scanner's locale.27.MatchResultmatch()Returns the match result of the last scanning operation performed by this scanner.28.Stringnext()Finds and returns the next complete token from this scanner.29.Stringnext(Pattern pattern)Returns the next token if it matches the specified pattern.30.Stringnext(String pattern)Returns the next token if it matches the pattern constructed from the specified string.31.BigDecimalnextBigDecimal()Scans the next token of the input as a BigDecimal.32.BigIntegernextBigInteger()Scans the next token of the input as a BigInteger.33.BigIntegernextBigInteger(int radix)Scans the next token of the input as a BigInteger.34.booleannextBoolean()Scans the next token of the input into a boolean value and returns that value.35.bytenextByte()Scans the next token of the input as a byte.36.bytenextByte(int radix)Scans the next token of the input as a byte.37.doublenextDouble()Scans the next token of the input as a float.38.intnextInt()Scans the next token of the input as an int.39.intnextInt(int radix)Scans the next token of the input as an int.40.StringnextLine()Advances this scanner past the current line and returns the input that was skipped.41.longnextLong()Scans the next token of the input as a long.42.longnextLong(int radix)Scans the next token of the input as a long.43.shortnextShort()Scans the next token of the input as a short.44.shortnextShort(int radix)Scans the next token of the input as a short.45.intradix()Returns this scanner's default radix.46.voidremove()The remove operation is not supported by this implementation of Iterator.47.Scannerreset()Resets this scanner.48.Scannerskip(Pattern pattern)Skips input that matches the specified pattern, ignoring delimiters.49.Scannerskip(String pattern)Skips input that matches a pattern constructed from the specified string.50.StringtoString()Returns the string representation of this Scanner.51.ScanneruseDelimiter(Pattern pattern)Sets this scanner's delimiting pattern to the specified pattern.52.ScanneruseDelimiter(String pattern)Sets this scanner's delimiting pattern to a pattern constructed from the specified String.53.ScanneruseLocale(Locale locale)Sets this scanner's locale to the specified locale.54.ScanneruseRadix(int radix)Sets this scanner's default radix to the specified radix.\n\n\n\n4. Scanner Java Example\n\n\n\nLet's see a Scanner Java Example.\n\n\n\nJavaUtilScannerExample.java\n\n\n\n\n\n\n\n\n\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n\n\n\npackage com.javacodegeeks.examples;\n \nimport java.util.Scanner;\n \npublic class JavaUtilScannerExample {\n \n public static void main(String[] args) {\n \/\/ Create a Scanner object\n try (Scanner scanner = new Scanner(System.in)) {\n \n \/\/ Read values from Console\n \n \/\/ A String value\n System.out.print(\"Enter Item Code: \");\n String itemCode = scanner.next();\n \n \/\/ A double value\n System.out.print(\"Enter Price: \");\n double price = scanner.nextDouble();\n \n \/\/ An int value\n System.out.print(\"Enter Quantity: \");\n int quantity = scanner.nextInt();\n \n \/\/ Display entered values\n double total = price * quantity;\n System.out.println();\n System.out.printf(\"%d %s @ %f = %f\", quantity, itemCode, price, total);\n \n \/\/ Read three int values\n System.out.printf(\"Enter three integer values: \");\n int i1 = scanner.nextInt();\n int i2 = scanner.nextInt();\n int i3 = scanner.nextInt();\n \n \/\/ Calculate the average and display the result\n int avg = (i1 + i2 + i3) \/ 3;\n \n System.out.printf(\"Average: %d\", avg);\n } catch (Exception e) {\n e.printStackTrace(System.err);\n }\n }\n}\n\n\n\n\n\n\n\n\n\n\nLet\u2019s explain the methods used in the above example.\n\n\n\npublic Scanner(InputStream source) - Constructs a new Scanner that produces values scanned from the specified input stream. Bytes from the stream are converted into characters using the underlying platform's default charset.public String next() - Finds and returns the next complete token from this scanner. A complete token is preceded and followed by input that matches the delimiter pattern. This method may block while waiting for input to scan, even if a previous invocation of hasNext() returned true.public double nextDouble() - Scans the next token of the input as a double. This method will throw InputMismatchException if the next token cannot be translated into a valid double value. If the translation is successful, the scanner advances past the input that matched.public int nextInt() - Scans the next token of the input as an int.\n\n\n\nIf we run the above code, we will get the following results:\n\n\n\n\n\n\n\n\n\n1\n2\n3\n4\n5\n6\n7\n8\n\n\n\nEnter Item Code: 1\nEnter Price: 10\nEnter Quantity: 5\n \n5 1 @ 10.000000 = 50.000000\n \nEnter three integer values: 1 2 3\nAverage: 2\n\n\n\n\n\n\n\n\n\n\n5. Common use of java.util.Scanner class\n\n\n\nA common programming task involves parsing a string of text into words or \u201ctokens\u201d that are separated by some set of delimiter characters, such as spaces or commas.\n\n\n\nScannerTokenizingText.java\n\n\n\n\n\n\n\n\n\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n\n\n\npackage com.javacodegeeks.examples;\n \nimport java.util.Scanner;\n \npublic class ScannerTokenizingText {\n @SuppressWarnings(\"resource\")\n public static void main(String[] args) {\n String text = \"4231, Java Programming, 1000.00\";\n \n Scanner scanner = new Scanner(text).useDelimiter(\"\\\\s*,\\\\s*\");\n int checkNumber = scanner.nextInt();\n String description = scanner.next();\n float amount = scanner.nextFloat();\n \n System.out.printf(\"\/***** Tokenizing Text *****\/\\n\\n\");\n \n System.out.printf(\"String to tokenize: %s\\n\", text);\n System.out.printf(\"checkNumber: %d\\n\", checkNumber);\n System.out.printf(\"description: %s\\n\", description);\n System.out.printf(\"amount: %f\", amount);\n }\n}\n\n\n\n\n\n\n\n\n\n\nLet\u2019s explain the methods used in the above example.\n\n\n\npublic float nextFloat() - Scans the next token of the input as a float. This method will throw InputMismatchException if the next token cannot be translated into a valid float value as described below. If the translation is successful, the scanner advances past the input that matched.public Scanner useDelimiter(String pattern) - Sets this scanner's delimiting pattern to a pattern constructed from the specified String. An invocation of this method of the form useDelimiter(pattern) behaves in exactly the same way as the invocation useDelimiter(Pattern.compile(pattern)). Invoking the reset() method will set the scanner's delimiter to the default.\n\n\n\nIf we run the above code, we will get the following results:\n\n\n\n\n\n\n\n\n\n1\n2\n3\n4\n5\n6\n\n\n\n\/***** Tokenizing Text *****\/\n \nString to tokenize: 4231, Java Programming, 1000.00\ncheckNumber: 4231\ndescription: Java Programming\namount: 1000.000000\n\n\n\n\n\n\n\n\n\n\n6. Not so common use of java.util.Scanner class\n\n\n\nThe java.util.Scanner provides a single API for not only parsing indi\u2010 vidual primitive types from strings, but reading them from a stream of tokens.\n\n\n\nThe Scanner API is smarter and can use Locales to parse numbers in specific languages with more elaborate conventions. You can specify a Locale other than the default with the useLocale() method.\n\n\n\nJavaNetURLMoreMethodsExample.java\n\n\n\n\n\n\n\n\n\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n\n\n\npackage com.javacodegeeks.examples;\n \nimport java.util.InputMismatchException;\nimport java.util.Locale;\nimport java.util.Scanner;\n \npublic class ScannerUncommonUses {\n @SuppressWarnings(\"resource\")\n public static void main(String[] args) {\n \n \/\/ Parsing primitive numbers\n boolean bl = new Scanner(\"false\").nextBoolean();\n byte b = new Scanner(\"16\").nextByte();\n int n = new Scanner(\"42\").nextInt();\n long l = new Scanner(\"99999999999\").nextLong();\n float f = new Scanner(\"4.2\").nextFloat();\n double d = new Scanner(\"99.99999999\").nextDouble();\n \n System.out.printf(\"\/***** Parsing primitive numbers *****\/\\n\\n\");\n System.out.printf(\"boolean: %b\\n\", bl);\n System.out.printf(\"byte: %d\\n\", b);\n System.out.printf(\"int: %d\\n\", n);\n System.out.printf(\"long: %d\\n\", l);\n System.out.printf(\"float: %f\\n\", f);\n System.out.printf(\"double: %f\\n\\n\", d);\n \n \/\/ Using Locale to parse numbers in specific languages\n try {\n double doubleLocale = new Scanner(\"1.234,56\").useLocale(\n Locale.ITALIAN).nextDouble();\n \n System.out.printf(\"\/***** Using Locales to parse numbers in specific languages *****\/\\n\\n\");\n System.out.printf(\"double (Locale = Italy): %f\", doubleLocale);\n } catch (InputMismatchException ime) {\n ime.printStackTrace(System.err);\n }\n }\n}\n\n\n\n\n\n\n\n\n\n\nLet\u2019s explain the methods used in the above example.\n\n\n\npublic byte nextByte() - Scans the next token of the Java input as a byte.public long nextLong() - Scans the next token of the Java input as a long.public Scanner useLocale(Locale locale) - Sets this scanner's locale to the specified locale. A scanner's locale affects many elements of its default primitive matching regular expressions; see localized numbers above. Invoking the reset() method will set the scanner's locale to the initial locale.\n\n\n\nIf we run the above code, we will get the following results:\n\n\n\n\n\n\n\n\n\n01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12\n\n\n\n\/***** Parsing primitive numbers *****\/\n \nboolean: false\nbyte: 16\nint: 42\nlong: 99999999999\nfloat: 4.200000\ndouble: 100.000000\n \n\/***** Using Locales to parse numbers in specific languages *****\/\n \ndouble (Locale = Italy): 1234.560000\n\n\n\n\n\n\n\n\n\n\n7. More articles\n\n\n\nJava String Class ExampleString CompareTo Java Example\n\n\n\n8. Download the source code\n\n\n\nThat was an example about the java.util.Scanner class. We also saw how to use this class to read a Java input form the console. \n\n\n\nDownload\nYou can download the source code of this example from here: java.util.Scanner - Scanner Java Example\n\n\n\nLast updated on Apr. 27th, 2021\n","publisher":{"@id":"#Publisher","@type":"Organization","name":"Examples Java Code Geeks","logo":{"@type":"ImageObject","url":"\/wp-content\/uploads\/2013\/05\/JavaCodeGeeks-logo.png"},"sameAs":["https:\/\/feeds.feedburner.com\/examplesjavacodegeeks","https:\/\/www.facebook.com\/javacodegeeks","https:\/\/twitter.com\/javacodegeeks","https:\/\/www.linkedin.com\/groups\/3810709\/","https:\/\/www.youtube.com\/channel\/UCxoUc7Rar2q90Gu0nT2ffuQ","https:\/\/github.com\/javacodegeeks\/"]},"sourceOrganization":{"@id":"#Publisher"},"copyrightHolder":{"@id":"#Publisher"},"mainEntityOfPage":{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/java-util-scanner-scanner-java-example\/","breadcrumb":{"@id":"#Breadcrumb"}},"author":{"@type":"Person","name":"Armando Flores","url":"https:\/\/examples.javacodegeeks.com\/author\/armando-flores\/"},"image":{"@type":"ImageObject","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","width":1200,"height":150}}
| og:locale | en_US |
| og:type | article |
| og:site_name | Examples Java Code Geeks |
| article:publisher | https://www.facebook.com/javacodegeeks |
| article:published_time | 2014-07-09T08:00:32+00:00 |
| article:modified_time | 2022-07-06T11:24:40+00:00 |
| og:image | https://examples.javacodegeeks.com/wp-content/uploads/2012/12/java-logo.jpg |
| og:image:width | 150 |
| og:image:height | 150 |
| og:image:type | image/jpeg |
| author | Armando Flores |
| twitter:card | summary_large_image |
| twitter:creator | @javacodegeeks |
| twitter:label1 | Written by |
| twitter:data1 | Armando Flores |
| twitter:label2 | Est. reading time |
| twitter:data2 | 12 minutes |
| None | IE=edge |
| msapplication-TileImage | https://examples.javacodegeeks.com/wp-content/uploads/2013/05/JavaCodeGeeks-favIcon.png |
Links:
Viewport: width=device-width, initial-scale=1.0
Robots: index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1