{"id":19358,"date":"2020-07-11T11:52:44","date_gmt":"2020-07-11T18:52:44","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=19358"},"modified":"2023-12-01T03:54:35","modified_gmt":"2023-12-01T11:54:35","slug":"java-random-number","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/java-random-number\/","title":{"rendered":"Java Random Number: A Beginner\u2019s Guide"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">How to Generate a Java Random Number<\/h2>\n\n\n\n<p>5. 7. 22. For us humans, it\u2019s easy to generate a random number. All we have to do is ask ourselves for a number, and one pops into our mind.<br><\/p>\n\n\n\n<p>If only it were so easy in programming, right? In Java, generating a random number is easy, if you know how.<br><\/p>\n\n\n\n<p>In this guide, we\u2019re going to discuss three approaches you can use to generate a random number. We\u2019ll walk through examples of how each method works in the context of a number guessing game.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Generating a Random Number<\/h2>\n\n\n\n<p>We\u2019ve all played one of those games that ask you to guess a number at some point. Some of them even award prizes if you can guess the right one. For this guide, we\u2019re going to create a number guessing game in Java.<br><\/p>\n\n\n\n<p>The first step is, of course, to generate a random number. Without a random number, our game would not be very fun. Let\u2019s walk through each of the three methods we can use to do this.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Using the Random Class<\/h3>\n\n\n\n<p>Java has a handy class called \u201cRandom\u201d which you can use to generate a random number. We\u2019ll start our number guessing game by using the <code>java.util.Random<\/code> class to generate a stream of random numbers:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import java.util.Random;\nclass Main {\n\tpublic static void main(String args[]) {\n\t\tRandom random_number_generator = new Random();\n\t\tint random_number = random_number_generator.nextInt(25);\n\t\tSystem.out.println(random_number);\n\t}\n}<\/pre><\/div>\n\n\n\n<p>When we run this class three times, three random numbers are generated:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>22\n15\n19<\/pre><\/div>\n\n\n\n<p>We\u2019ve started by importing the class, <code>java.util.Random<\/code>. Then, we have created an instance of this class called \u201crandom_number_generator\u201d. Using this instance, we can generate random numbers.<br><\/p>\n\n\n\n<p>The <code>nextInt()<\/code> method allows us to generate a random number between the range of 0 and another specified number. Above, we specified the number 25. This means that all the numbers our generator will return will be between 0 and 25.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Using Math.random()<\/h3>\n\n\n\n<p>The <a href=\"https:\/\/careerkarma.com\/blog\/java-math-random\/\">Math.random()<\/a> method takes a little bit more work to use, but it\u2019s still a good way to generate a random number. Let\u2019s create a random number generator sequence using <code>Math.random()<\/code>:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>class Main {\n\tpublic static void main(String args[]) {\n\t\tint small = 0;\n\t\tint large = 25;\n\t\tint random_number = (int)(Math.random() * (large - small + 1) + small);\n\t\tSystem.out.println(random_number);\n\t}\n}<\/pre><\/div>\n\n\n\n<p><code>Math.random()<\/code> comes built into Java. This means that we don\u2019t have to import it in our code.<br><\/p>\n\n\n\n<p>We\u2019ve started by declaring two variables. \u201csmall\u201d specifies the lower bound below which no number should be generated; \u201clarge\u201d is the upper bound above which no number should be generated.<br><\/p>\n\n\n\n<p>We\u2019ve then used a formula to generate a random number. This is because <code>Math.random()<\/code> in itself does not return a whole random number. The Math.random method returns a random number between 0.0 and 1.0. We\u2019ve got to use the formula above to convert it to a whole number that\u2019s within our range.<br><\/p>\n\n\n\n<p>When we run our code three times, three random numbers are generated:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>2\n1\n9<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Using ThreadLocalRandom<\/h3>\n\n\n\n<p>ThreadLocalRandom is a class that you can use to generate random numbers.<br><\/p>\n\n\n\n<p>This class is best to use when you want to generate multiple random numbers in parallel. This typically happens in multi-threading environments.&nbsp;<br><\/p>\n\n\n\n<p>Let\u2019s create a random number generator using this method:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import java.util.concurrent.ThreadLocalRandom;\nclass Main {\n\tpublic static void main(String args[]) {\n\t\tint small = 0;\n\t\tint large = 25;\n\t\tThreadLocalRandom random_number_generator = ThreadLocalRandom.current();\n\t\tint random_number = random_number_generator.nextInt(small, large);\n\t\tSystem.out.println(random_number);\n\t}\n}<\/pre><\/div>\n\n\n\n<p>We\u2019ve started by importing the ThreadLocalRandom library that contains the class we are using to generate a random number. Then we\u2019ve specified two variables which set the lower and upper bounds for our random number generator.<br><\/p>\n\n\n\n<p>We\u2019ve declared a variable called random_number_generator which references the ThreadLocalRandom class. We\u2019ve then used the <code>nextInt()<\/code> method and specified our \u201csmall\u201d and \u201clarge\u201d variables as arguments in order to generate a random number.<br><\/p>\n\n\n\n<p>Executing our program three times returns three random numbers:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>4\n23\n15<\/pre><\/div>\n\n\n\n<p>Now we\u2019re ready to start building the rest of our guessing game.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Creating the Guess Logic<\/h2>\n\n\n\n<p>We now know how to generate a random number. The next step in building our game is to create the logic that allows a user to guess a random number.<br><\/p>\n\n\n\n<p>You can use any of the above examples with this code to make it work. The variable names in our code snippets have been set up so that they are compatible with the below example.<br><\/p>\n\n\n\n<p>Let\u2019s start by using the \u201cScanner\u201d class to ask a user to guess a number:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import java.util.Scanner;\nclass Main {\n\tpublic static void main(String[] args) {\n\t\t\/\/ Guessing code goes here\n\t\tScanner guess = new Scanner(System.in);\n\t\tSystem.out.println(\"Guess a number between 1 and 25: \");\n\t\tint user_guess = guess.nextInt();\n\t}\n}<\/pre><\/div>\n\n\n\n<p>This code asks our user to \u201cGuess a number between 1 and 25: \u201d. The value that the user enters into the Java console will be stored as the variable \u201cuser_guess\u201d.<br><\/p>\n\n\n\n<p>We\u2019re then going to write an if statement that checks if the number the user has guessed is equal to the one our program has generated:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>...\nif (user_guess == random_number) {\n\tSystem.out.println(\"You have correctly guessed the number!\");\n} else {\n\tSystem.out.println(\"Your guess is incorrect!\");\n}<\/pre><\/div>\n\n\n\n<p>Let\u2019s run our program and type in a number between 1 and 25:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Guess a number between 1 and 25:\n7\nYour guess is incorrect!<\/pre><\/div>\n\n\n\n<p>If we guess the number correctly, the following is returned by our program:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Guess a number between 1 and 25:\n9\nYou have correctly guessed the number!<\/pre><\/div>\n\n\n\n<p>With only a few lines of code, we\u2019ve been able to successfully create a game that generates a random number to guess.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Random numbers have a wide range of uses in programming. In this example, we\u2019ve walked through how a random number could be used with a guessing game.<br><\/p>\n\n\n\n<p>There are three methods you can use to generate random numbers:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Using the Random class<\/li>\n\n\n\n<li>Using the built-in <code>Math.random()<\/code> method<\/li>\n\n\n\n<li>Using the ThreadLocalRandom class<\/li>\n<\/ul>\n\n\n\n<p>Are you looking for a challenge? Change our guessing game code so that you can make multiple guesses.<\/p>\n","protected":false},"excerpt":{"rendered":"How to Generate a Java Random Number 5. 7. 22. For us humans, it\u2019s easy to generate a random number. All we have to do is ask ourselves for a number, and one pops into our mind. If only it were so easy in programming, right? In Java, generating a random number is easy, if&hellip;","protected":false},"author":240,"featured_media":19359,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[17289],"tags":[],"class_list":{"0":"post-19358","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":"","is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.4 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Java Random Number: A Beginner\u2019s Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"On Career Karma, learn how to generate a Java random number using the Math.random() method, the Random class, and the ThreadLocalRandom class.\" \/>\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-random-number\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java Random Number: A Beginner\u2019s Guide\" \/>\n<meta property=\"og:description\" content=\"On Career Karma, learn how to generate a Java random number using the Math.random() method, the Random class, and the ThreadLocalRandom class.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/java-random-number\/\" \/>\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-07-11T18:52:44+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T11:54:35+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/andrew-buchanan-GlOlfHtzXVk-unsplash.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1020\" \/>\n\t<meta property=\"og:image:height\" content=\"618\" \/>\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=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-random-number\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-random-number\\\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"Java Random Number: A Beginner\u2019s Guide\",\"datePublished\":\"2020-07-11T18:52:44+00:00\",\"dateModified\":\"2023-12-01T11:54:35+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-random-number\\\/\"},\"wordCount\":850,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-random-number\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/07\\\/andrew-buchanan-GlOlfHtzXVk-unsplash.jpg\",\"articleSection\":[\"Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-random-number\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-random-number\\\/\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-random-number\\\/\",\"name\":\"Java Random Number: A Beginner\u2019s Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-random-number\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-random-number\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/07\\\/andrew-buchanan-GlOlfHtzXVk-unsplash.jpg\",\"datePublished\":\"2020-07-11T18:52:44+00:00\",\"dateModified\":\"2023-12-01T11:54:35+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"On Career Karma, learn how to generate a Java random number using the Math.random() method, the Random class, and the ThreadLocalRandom class.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-random-number\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-random-number\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-random-number\\\/#primaryimage\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/07\\\/andrew-buchanan-GlOlfHtzXVk-unsplash.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/07\\\/andrew-buchanan-GlOlfHtzXVk-unsplash.jpg\",\"width\":1020,\"height\":618},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-random-number\\\/#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 Random Number: A Beginner\u2019s 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\\\/wp-content\\\/uploads\\\/2020\\\/01\\\/james-gallagher-150x150.jpg\",\"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 Random Number: A Beginner\u2019s Guide | Career Karma","description":"On Career Karma, learn how to generate a Java random number using the Math.random() method, the Random class, and the ThreadLocalRandom class.","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-random-number\/","og_locale":"en_US","og_type":"article","og_title":"Java Random Number: A Beginner\u2019s Guide","og_description":"On Career Karma, learn how to generate a Java random number using the Math.random() method, the Random class, and the ThreadLocalRandom class.","og_url":"https:\/\/careerkarma.com\/blog\/java-random-number\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-07-11T18:52:44+00:00","article_modified_time":"2023-12-01T11:54:35+00:00","og_image":[{"width":1020,"height":618,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/andrew-buchanan-GlOlfHtzXVk-unsplash.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":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/java-random-number\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/java-random-number\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"Java Random Number: A Beginner\u2019s Guide","datePublished":"2020-07-11T18:52:44+00:00","dateModified":"2023-12-01T11:54:35+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/java-random-number\/"},"wordCount":850,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/java-random-number\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/andrew-buchanan-GlOlfHtzXVk-unsplash.jpg","articleSection":["Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/java-random-number\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/java-random-number\/","url":"https:\/\/careerkarma.com\/blog\/java-random-number\/","name":"Java Random Number: A Beginner\u2019s Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/java-random-number\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/java-random-number\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/andrew-buchanan-GlOlfHtzXVk-unsplash.jpg","datePublished":"2020-07-11T18:52:44+00:00","dateModified":"2023-12-01T11:54:35+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"On Career Karma, learn how to generate a Java random number using the Math.random() method, the Random class, and the ThreadLocalRandom class.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/java-random-number\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/java-random-number\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/java-random-number\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/andrew-buchanan-GlOlfHtzXVk-unsplash.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/07\/andrew-buchanan-GlOlfHtzXVk-unsplash.jpg","width":1020,"height":618},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/java-random-number\/#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 Random Number: A Beginner\u2019s 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\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","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\/19358","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=19358"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/19358\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/19359"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=19358"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=19358"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=19358"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}