{"id":13483,"date":"2020-11-01T03:17:44","date_gmt":"2020-11-01T11:17:44","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=13483"},"modified":"2023-12-01T04:03:29","modified_gmt":"2023-12-01T12:03:29","slug":"java-math-random","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/java-math-random\/","title":{"rendered":"How to Use Java Math.random"},"content":{"rendered":"\n<p><em>The <code>Math.random()<\/code><\/em><a href=\"https:\/\/careerkarma.com\/blog\/java-project-ideas\/\"><em>Java<\/em><\/a><em>&nbsp;method generates a pseudorandom number between 0.0 and 1.0. The resulting random number can be multiplied to get a range outside 0-1, and the result can be 0 but is always less than 1.&nbsp;<\/em><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>When you\u2019re programming, there are often situations where you need to generate a random number. For instance, say that you are operating a cruise line. You may want to generate a random number that is added to the end of a customer\u2019s order and used as their booking reference. Or you may want to generate a random number for a guessing game.<\/p>\n\n\n\n<p>In&nbsp;Java, there are a number of&nbsp;<a href=\"https:\/\/careerkarma.com\/blog\/java-methods\/\">methods<\/a>&nbsp;that can be used to generate a random number.<\/p>\n\n\n\n<p>In this tutorial, we are going to walk through the most common method used to generate a random number in Java: <code>Math.random(). <\/code>We\u2019ll also discuss a step-by-step example of how to use the<code> Math.random()<\/code> method.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"683\" src=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/11\/photo-1453060113865-968cea1ad53a-1024x683.jpeg\" alt=\"Man in front of Apple laptop screen showing code. \" class=\"wp-image-25069\" srcset=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/11\/photo-1453060113865-968cea1ad53a-1024x683.jpeg 1024w, https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/11\/photo-1453060113865-968cea1ad53a-768x512.jpeg 768w, https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/11\/photo-1453060113865-968cea1ad53a-770x513.jpeg 770w, https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/11\/photo-1453060113865-968cea1ad53a-20x13.jpeg 20w, https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/11\/photo-1453060113865-968cea1ad53a-385x257.jpeg 385w, https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/11\/photo-1453060113865-968cea1ad53a.jpeg 1050w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Java Math Library<\/h2>\n\n\n\n<p>The Java Math <a href=\"https:\/\/careerkarma.com\/blog\/java-class-object\/\">class<\/a> includes a number of features used to perform mathematical functions on numbers. For instance, the Math library includes the <code>round() <\/code>method that is used to round a number and the <code>pow()<\/code> method that is used to calculate the power of a number.<br><\/p>\n\n\n\n<p>In order to use the Java Math library, we must first import it into our code. We can do so using an import statement like this:\n<\/p>\n\n\n\n<p><code>import java.lang.Math;<\/code><\/p>\n\n\n\n<p><br>For this tutorial, we are going to use one method from the Math library: <code>Math.random().<\/code><br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Math.random Java Method<\/h2>\n\n\n\n<p>The Java <code>Math.random()<\/code> method is used to generate a&nbsp;<a href=\"https:\/\/careerkarma.com\/blog\/java-random-number\/\">pseudorandom number<\/a>, which is a number created with a formula that simulates randomness. The pseudorandom number will be greater than or equal to 0.0 and less than 1.0. In other words, the number generated by&nbsp; <code>Math.random<\/code> is always between 0 and 1, and is a floating-point number.<br><\/p>\n\n\n\n<p>The random method returns a random double, which is the data type used to store floating-point values.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Math.Random() Example<\/h2>\n\n\n\n<p>Here\u2019s an example of the <code>Math.random()<\/code> method in action:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>import java.lang.Math;\n\nclass Main {\n\tpublic static void main(String[] args) {\n\t\tdouble number = Math.random();\n\t\tSystem.out.println(&quot;Random number: &quot; + number);\n\t}\n}\n<\/pre><\/div>\n\n\n\n<p>Our code returns:<br><\/p>\n\n\n\n<p><code>Random number: 0.4728164736886452<br><\/code><\/p>\n\n\n\n<p>As you can see, our program has returned a random number between 0 and 1. However, this number is not very useful in its current form. If we want to generate a random number for a guessing game, for instance, we would not want to have a decimal number.<\/p>\n\n\n\n<p>In order to produce a whole number with our pseudorandom number generator, we can multiply our random number by another number and round it to the nearest whole number. For instance, suppose we wanted to generate a random number between 1 and 10. We could do so using this code:<\/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 number = (int)(Math.random() * 10);\n\t\tSystem.out.println(&quot;Random number: &quot; + number);\n\t}\n}\n<\/pre><\/div>\n\n\n\n<p>Here is the result of our program after running it three times:<br><\/p>\n\n\n\n<p>4<\/p>\n\n\n\n<p>6<\/p>\n\n\n\n<p>2<br><\/p>\n\n\n\n<p>As you can see, our program returns a random integer, or whole number.<\/p>\n\n\n\n<p>Let\u2019s break down our code. First, we declared a class called Main which stores the code for our program.<\/p>\n\n\n\n<p>Then we used the <code>Math.random() <\/code>method to generate a random number, and we multiplied that number by 10. After we multiplied the result by 10, we converted it to an integer, which rounds it to the nearest decimal place and gives us a whole number.&nbsp;<\/p>\n\n\n\n<p>Then, on the final line, we print out the message \u201cRandom number: \u201c to the console, followed by the random number our program generated.<\/p>\n\n\n\n<p>If we wanted to generate a larger number, we could replace the * 10 parts of our code with another number. For instance, say we wanted to generate a number between 1 and 1000. We could do so by replacing * 10 with * 1000 like this:<\/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 number = (int)(Math.random() * 1000);\n\t\tSystem.out.println(&quot;Random number: &quot; + number);\n\t}\n}\n<\/pre><\/div>\n\n\n\n<p>After executing our program three times, the following response was returned:<br><\/p>\n\n\n\n<p>181<\/p>\n\n\n\n<p>914<\/p>\n\n\n\n<p>939<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Java Math.random Between Two Numbers<\/h2>\n\n\n\n<p>The <code>Math.random() <\/code>method does not accept any arguments, which means that there is no way to influence the number generated by the method. However, we can create our own&nbsp;<a href=\"https:\/\/careerkarma.com\/blog\/java-methods\/\">method<\/a>&nbsp;which allows us to generate numbers between a particular range.<\/p>\n\n\n\n<p>For instance, suppose we are&nbsp;<a href=\"https:\/\/careerkarma.com\/blog\/game-dev-with-java\/\">building an app<\/a>&nbsp;that generates the random numbers which will be used to distinguish a customer\u2019s order at a cruise line. These numbers will be added onto the end of a customer\u2019s name.<\/p>\n\n\n\n<p>The number we want to generate should be between 200 and 500. In order to generate this number and prepare the customer\u2019s order reference, we could use this code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>class Main {\n\tpublic static int generateTicketNumber(int min, int max) {\n\t\tint range = (max - min) + 1;\n\t\treturn (int)(Math.random() * range) + min;\n\t}\n\n\tpublic static void main(String args[]) {\n\t\tString customerName = &quot;JohnMcIver&quot;;\n\t\tint randomNumber = generateTicketNumber(200, 500);\n\t\tSystem.out.println(customerName + randomNumber);\n\t}\n}\n<\/pre><\/div>\n\n\n\n<p>Our code returns:<br><\/p>\n\n\n\n<p><code>JohnMcIver321<br><\/code><\/p>\n\n\n\n<p>In our program, we generate a random number between the range of 200 and 500. Then we append that number to the customer\u2019s name and print out the result to the console.\n<\/p>\n\n\n\n<p>Let\u2019s break down how our code works:<br><\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>We declare a method called <code>generateTicketNumber() <\/code>which accepts two parameters: min and max.<\/li><li><code>generateTicketNumber() <\/code>uses the min and max parameters to generate a random number within the range of those two numbers with <code>Math.random().<\/code><\/li><li>When the main program runs, a <a href=\"https:\/\/careerkarma.com\/blog\/java-variables\/\">variable<\/a> called <code>customerName<\/code> is declared and is assigned the value <code>John McIver<\/code>.<\/li><li>Then the <code>generateTicketNumber()<\/code> method is called and the parameters 200 and 500 are specified, which correspond to the min and max values in the range our result should fall in, respectively. The result of this method is assigned to the variable <code>randomNumber<\/code>.<\/li><li>The customer\u2019s name and the random number generated are concatenated\u2014or merged together\u2014and printed to the console.<\/li><\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>The Java <code>Math.random() <\/code>method is used to generate pseudo-random numbers. <code>Math.random()<\/code> generates a number between 0 and 1, which can then be manipulated to be within a certain range.<br><\/p>\n\n\n\n<p>This tutorial discussed the basics of the Math library in Java and how you can use the <code>Math.random()<\/code> method to generate random numbers. Additionally, this tutorial explored how to generate a random number between a range of two numbers using <code>Math.random()<\/code> and a custom method.<br><\/p>\n\n\n\n<p>You\u2019re now ready to start generating random numbers in Java like a pro!<\/p>\n","protected":false},"excerpt":{"rendered":"The Math.random()Java&nbsp;method generates a pseudorandom number between 0.0 and 1.0. The resulting random number can be multiplied to get a range outside 0-1, and the result can be 0 but is always less than 1.&nbsp; When you\u2019re programming, there are often situations where you need to generate a random number. For instance, say that you&hellip;","protected":false},"author":240,"featured_media":13484,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[17289],"tags":[],"class_list":{"0":"post-13483","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.4 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Use Java Math.random: A Step-By-Step Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"Math.random is a Java math method that allows developers to generate pseudo-random numbers. Learn more in this article.\" \/>\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-math-random\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Use Java Math.random\" \/>\n<meta property=\"og:description\" content=\"Math.random is a Java math method that allows developers to generate pseudo-random numbers. Learn more in this article.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/java-math-random\/\" \/>\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-01T11:17:44+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T12:03:29+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/three-woman-sitting-on-white-chair-in-front-of-table-2041627.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"667\" \/>\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=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-math-random\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-math-random\\\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"How to Use Java Math.random\",\"datePublished\":\"2020-11-01T11:17:44+00:00\",\"dateModified\":\"2023-12-01T12:03:29+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-math-random\\\/\"},\"wordCount\":934,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-math-random\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/three-woman-sitting-on-white-chair-in-front-of-table-2041627.jpg\",\"articleSection\":[\"Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-math-random\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-math-random\\\/\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-math-random\\\/\",\"name\":\"How to Use Java Math.random: A Step-By-Step Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-math-random\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-math-random\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/three-woman-sitting-on-white-chair-in-front-of-table-2041627.jpg\",\"datePublished\":\"2020-11-01T11:17:44+00:00\",\"dateModified\":\"2023-12-01T12:03:29+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/#\\\/schema\\\/person\\\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"Math.random is a Java math method that allows developers to generate pseudo-random numbers. Learn more in this article.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-math-random\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-math-random\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-math-random\\\/#primaryimage\",\"url\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/three-woman-sitting-on-white-chair-in-front-of-table-2041627.jpg\",\"contentUrl\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/three-woman-sitting-on-white-chair-in-front-of-table-2041627.jpg\",\"width\":1000,\"height\":667},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/careerkarma.com\\\/blog\\\/java-math-random\\\/#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\":\"How to Use Java Math.random\"}]},{\"@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":"How to Use Java Math.random: A Step-By-Step Guide | Career Karma","description":"Math.random is a Java math method that allows developers to generate pseudo-random numbers. Learn more in this article.","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-math-random\/","og_locale":"en_US","og_type":"article","og_title":"How to Use Java Math.random","og_description":"Math.random is a Java math method that allows developers to generate pseudo-random numbers. Learn more in this article.","og_url":"https:\/\/careerkarma.com\/blog\/java-math-random\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-11-01T11:17:44+00:00","article_modified_time":"2023-12-01T12:03:29+00:00","og_image":[{"width":1000,"height":667,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/three-woman-sitting-on-white-chair-in-front-of-table-2041627.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":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/java-math-random\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/java-math-random\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"How to Use Java Math.random","datePublished":"2020-11-01T11:17:44+00:00","dateModified":"2023-12-01T12:03:29+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/java-math-random\/"},"wordCount":934,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/java-math-random\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/three-woman-sitting-on-white-chair-in-front-of-table-2041627.jpg","articleSection":["Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/java-math-random\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/java-math-random\/","url":"https:\/\/careerkarma.com\/blog\/java-math-random\/","name":"How to Use Java Math.random: A Step-By-Step Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/java-math-random\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/java-math-random\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/three-woman-sitting-on-white-chair-in-front-of-table-2041627.jpg","datePublished":"2020-11-01T11:17:44+00:00","dateModified":"2023-12-01T12:03:29+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"Math.random is a Java math method that allows developers to generate pseudo-random numbers. Learn more in this article.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/java-math-random\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/java-math-random\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/java-math-random\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/three-woman-sitting-on-white-chair-in-front-of-table-2041627.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/three-woman-sitting-on-white-chair-in-front-of-table-2041627.jpg","width":1000,"height":667},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/java-math-random\/#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":"How to Use Java Math.random"}]},{"@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\/13483","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=13483"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/13483\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/13484"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=13483"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=13483"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=13483"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}