{"id":86,"date":"2019-01-18T08:15:15","date_gmt":"2019-01-18T08:15:15","guid":{"rendered":"https:\/\/www.kindsonthegenius.com\/java\/?p=86"},"modified":"2020-08-06T09:53:24","modified_gmt":"2020-08-06T09:53:24","slug":"14-java-the-number-class","status":"publish","type":"post","link":"https:\/\/www.kindsonthegenius.com\/java\/14-java-the-number-class\/","title":{"rendered":"Java &#8211; The Number Class"},"content":{"rendered":"<p>I am sure you can use numbers now. At least you know about int, long, double etc. So these are primitive types. Take a few minutes to review <a href=\"https:\/\/www.kindsonthegenius.com\/java\/java-basic-data-types\/\">Data Types<\/a>.<\/p>\n<p>&nbsp;<\/p>\n<h4><strong>Primitive Types and Wrapper Types<\/strong><\/h4>\n<p>Primitive types can be declared like this:<\/p>\n<p>&nbsp;<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\">   <span style=\"color: #333399; font-weight: bold;\">int<\/span> score <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">90<\/span><span style=\"color: #333333;\">;<\/span>\r\n   <span style=\"color: #333399; font-weight: bold;\">float<\/span> value <span style=\"color: #333333;\">=<\/span> <span style=\"color: #6600ee; font-weight: bold;\">384.03f<\/span><span style=\"color: #333333;\">;<\/span>\r\n   <span style=\"color: #333399; font-weight: bold;\">char<\/span> initial <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0044dd;\">'K'<\/span><span style=\"color: #333333;\">;<\/span>\r\n   <span style=\"color: #333399; font-weight: bold;\">long<\/span> total <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">700834L<\/span><span style=\"color: #333333;\">;<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Java also provides us with Wrapper Classes. Although these are also\u00a0 numbers, they are actually objects. They include:<\/p>\n<ul>\n<li>Byte<\/li>\n<li>Short<\/li>\n<li>Integer<\/li>\n<li>Long<\/li>\n<li>Float<\/li>\n<li>Double<\/li>\n<\/ul>\n<p>These are wrapper classes and they derive from the Number class. This is part of java.lang package. Therefore, you can create objects from these classes. Object of these classes contains the equivalent primitive type. So it kind of &#8216;wraps&#8217; the corresponding primitive. Hence the name wrapper class.<\/p>\n<p>You can convert primitive type to wrapper type (object). This is called boxing. Similarly, you can convert wrapper object back to the corresponding primitive type. This is called unboxing.<\/p>\n<p>&nbsp;<\/p>\n<p>Let&#8217;s take an example of boxing. We also look at unboxing as well<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\">   <span style=\"color: #333399; font-weight: bold;\">int<\/span> a <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">10<\/span><span style=\"color: #333333;\">;<\/span>\t\t<span style=\"color: #888888;\">\/\/a is a primitive type, int<\/span>\r\n   Integer b <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">10<\/span><span style=\"color: #333333;\">;<\/span>\t<span style=\"color: #888888;\">\/\/b is a wrapper object, Integer (boxing)<\/span>\r\n   b <span style=\"color: #333333;\">=<\/span> b <span style=\"color: #333333;\">+<\/span> <span style=\"color: #0000dd; font-weight: bold;\">20<\/span><span style=\"color: #333333;\">;<\/span>\t\t<span style=\"color: #888888;\">\/\/this causes be to become a primitive type int (unboxing)<\/span>\r\n<\/pre>\n<p>From the code above, the can deduce that:<\/p>\n<ul>\n<li>Boxing creates a wrapper object from a primitive type<\/li>\n<li>Unboxing creates a primitive type from a wrapper object<\/li>\n<\/ul>\n<p>Oftentimes, you will only need to use primitive types. However, there are few occasion you probably will require wrapper objects.<\/p>\n<p>&nbsp;<\/p>\n<h4><strong>Method of the Number Classs<\/strong><\/h4>\n<p>We have some methods in the Number class that you need to know. So, let&#8217;s consider some of them.<\/p>\n<table class=\"table table-bordered\">\n<tbody>\n<tr style=\"background-color: #f7f6f3;\">\n<th>SN.<\/th>\n<th>Method and Description<\/th>\n<\/tr>\n<tr>\n<td class=\"ts\">1<\/td>\n<td><strong>intValue(), shortValue(), floatValue(), byteValue()<\/strong><\/p>\n<p>Converts the value of Number object to the primitive equivalent<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">2<\/td>\n<td><strong>compareTo()<\/strong><\/p>\n<p>Used to compare the Number object to another number given as argument.<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">3<\/td>\n<td><strong>equals()<\/strong><\/p>\n<p>Used to check whether the number object is equal to the given argument.<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">4<\/td>\n<td><strong>valueOf()<\/strong><\/p>\n<p>Used to create an Integer object holding the value of the specified primitive.<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">5<\/td>\n<td><strong>toString()<\/strong><\/p>\n<p>Used to create a String object representing the value of a specified int or Integer.<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">6<\/td>\n<td><strong>parseInt()<\/strong><\/p>\n<p>This method is used to get the primitive data type of a certain String.<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">7<\/td>\n<td><strong>abs()<\/strong><\/p>\n<p>Used to return the absolute value of the argument.<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">8<\/td>\n<td><strong>ceil()<\/strong><\/p>\n<p>Used to return the smallest integer that is greater than or equal to the argument.<\/p>\n<p>Returned a double.<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">9<\/td>\n<td><strong>floor()<\/strong><\/p>\n<p>Used to return the largest integer that is less than or equal to the argument.<\/p>\n<p>Returns a double.<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">10<\/td>\n<td><strong>rint()<\/strong><\/p>\n<p>Used to return the integer that is closest in value to the argument.<\/p>\n<p>Returns a double.<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">11<\/td>\n<td><strong>round()<\/strong><\/p>\n<p>Rounds a number to the closest long or int, as indicated by the method&#8217;s return type to the argument.<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">12<\/td>\n<td><strong>min()<\/strong><\/p>\n<p>Takes two arguments and return the smaller of the two.<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">13<\/td>\n<td><strong>max()<\/strong><\/p>\n<p>Takes two arguments and return the larger of the two.<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">14<\/td>\n<td><strong>exp()<\/strong><\/p>\n<p>Used to return the base of the natural logarithms, e, to the power of the argument.<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">15<\/td>\n<td><strong>log()<\/strong><\/p>\n<p>Used to return the natural logarithm of the given argument.<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">16<\/td>\n<td><strong>pow()<\/strong><\/p>\n<p>Takes two arguments and the value of the first argument raised to the power of the second argument.<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">17<\/td>\n<td><strong>sqrt()<\/strong><\/p>\n<p>Used to return the square root of the given argument.<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">18<\/td>\n<td><strong>sin()<\/strong><\/p>\n<p>Used to return the sine of the given double value.<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">19<\/td>\n<td><strong>cos()<\/strong><\/p>\n<p>Used to return the cosine of the given double value.<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">20<\/td>\n<td><strong>tan()<\/strong><\/p>\n<p>Used to return the tangent of the given double value.<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">21<\/td>\n<td><strong>asin()<\/strong><\/p>\n<p>Used to return the arcsine of the given double value.<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">22<\/td>\n<td><strong>acos()<\/strong><\/p>\n<p>Used to return the arccosine of the given double value.<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">23<\/td>\n<td><strong>atan()<\/strong><\/p>\n<p>Used to return the arctangent of the given double value.<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">24<\/td>\n<td><strong>atan2()<\/strong><\/p>\n<p>Used to convert the rectangular coordinates (x, y) to equivalent polar coordinate (r, theta) and returns theta.<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">25<\/td>\n<td><strong>toDegrees()<\/strong><\/p>\n<p>Used to convert an given argument to degrees.<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">26<\/td>\n<td><strong>toRadians()<\/strong><\/p>\n<p>Converts the argument\u00a0 to radians.<\/td>\n<\/tr>\n<tr>\n<td class=\"ts\">27<\/td>\n<td><strong>random()<\/strong><\/p>\n<p>Used to return a single random number.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Table 1.0: List of Methods of the Number class<\/p>\n<p>&nbsp;<\/p>\n<p>I would therefore recommend you try some of these methods to see how they work. I have provided the code below the demonstrates some of them.<\/p>\n<p>&nbsp;<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #888888;\">\/\/Testing the Methods of the Number Wrapper class<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">class<\/span> <span style=\"color: #bb0066; font-weight: bold;\">Tester<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\r\n   <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">static<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">main<\/span><span style=\"color: #333333;\">(<\/span>String args<span style=\"color: #333333;\">[])<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t   Integer x <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">10<\/span><span style=\"color: #333333;\">;<\/span>\r\n\t   Integer y <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">20<\/span><span style=\"color: #333333;\">;<\/span>\r\n\t   Integer z <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">30<\/span><span style=\"color: #333333;\">;<\/span>\r\n\t   Float w <span style=\"color: #333333;\">=<\/span> <span style=\"color: #6600ee; font-weight: bold;\">40.45f<\/span><span style=\"color: #333333;\">;<\/span>\r\n\t   \r\n\t   <span style=\"color: #333399; font-weight: bold;\">int<\/span> a <span style=\"color: #333333;\">=<\/span> Integer<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">parseInt<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"4\"<\/span><span style=\"color: #333333;\">);<\/span> <span style=\"color: #888888;\">\/\/creates in int value<\/span>\r\n\t   <span style=\"color: #333399; font-weight: bold;\">int<\/span> x1 <span style=\"color: #333333;\">=<\/span> x<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">intValue<\/span><span style=\"color: #333333;\">();<\/span>  <span style=\"color: #888888;\">\/\/unboxes x(Integer) to an int x1<\/span>\r\n\t   <span style=\"color: #333399; font-weight: bold;\">int<\/span> y1 <span style=\"color: #333333;\">=<\/span> y<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">intValue<\/span><span style=\"color: #333333;\">();<\/span>  <span style=\"color: #888888;\">\/\/unboxed y(Integer) to an int y1<\/span>\r\n\t   String strx <span style=\"color: #333333;\">=<\/span> x<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">toString<\/span><span style=\"color: #333333;\">();<\/span>  <span style=\"color: #888888;\">\/\/Creates a string equivalent of x<\/span>\r\n\t   <span style=\"color: #333399; font-weight: bold;\">int<\/span> c <span style=\"color: #333333;\">=<\/span> Integer<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">min<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #0000dd; font-weight: bold;\">4<\/span><span style=\"color: #333333;\">,<\/span><span style=\"color: #0000dd; font-weight: bold;\">5<\/span><span style=\"color: #333333;\">);<\/span>    <span style=\"color: #888888;\">\/\/returns the smaller of the two numbers<\/span>\r\n\t   <span style=\"color: #333399; font-weight: bold;\">int<\/span> d <span style=\"color: #333333;\">=<\/span> Integer<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">max<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #0000dd; font-weight: bold;\">4<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"color: #0000dd; font-weight: bold;\">5<\/span><span style=\"color: #333333;\">);<\/span>    <span style=\"color: #888888;\">\/\/returns the larger of the two numbers   \t\t  <\/span>\r\n   <span style=\"color: #333333;\">}<\/span>    \r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am sure you can use numbers now. At least you know about int, long, double etc. So these are primitive types. Take a few &hellip; <\/p>\n","protected":false},"author":395,"featured_media":97,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[2],"tags":[],"class_list":["post-86","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java-tutorial"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Java - The Number Class - Java Tutorials<\/title>\n<meta name=\"description\" content=\"In this tutorial, you will learn about the Numbers wrapper class. You will learn about boxing and unboxing as well as various methods of the number 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:\/\/www.kindsonthegenius.com\/java\/14-java-the-number-class\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java - The Number Class - Java Tutorials\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, you will learn about the Numbers wrapper class. You will learn about boxing and unboxing as well as various methods of the number class\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.kindsonthegenius.com\/java\/14-java-the-number-class\/\" \/>\n<meta property=\"og:site_name\" content=\"Java Tutorials\" \/>\n<meta property=\"article:published_time\" content=\"2019-01-18T08:15:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-08-06T09:53:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.kindsonthegenius.com\/java\/wp-content\/uploads\/sites\/9\/2019\/01\/Number-Class-in-Java.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"963\" \/>\n\t<meta property=\"og:image:height\" content=\"518\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"kindsonthegenius\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"kindsonthegenius\" \/>\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:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/14-java-the-number-class\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/14-java-the-number-class\\\/\"},\"author\":{\"name\":\"kindsonthegenius\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/#\\\/schema\\\/person\\\/63a68934672db675ff0cd80d066510c2\"},\"headline\":\"Java &#8211; The Number Class\",\"datePublished\":\"2019-01-18T08:15:15+00:00\",\"dateModified\":\"2020-08-06T09:53:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/14-java-the-number-class\\\/\"},\"wordCount\":638,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/14-java-the-number-class\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/wp-content\\\/uploads\\\/sites\\\/9\\\/2019\\\/01\\\/Number-Class-in-Java.jpg\",\"articleSection\":[\"Java Tutorial\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/14-java-the-number-class\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/14-java-the-number-class\\\/\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/14-java-the-number-class\\\/\",\"name\":\"Java - The Number Class - Java Tutorials\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/14-java-the-number-class\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/14-java-the-number-class\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/wp-content\\\/uploads\\\/sites\\\/9\\\/2019\\\/01\\\/Number-Class-in-Java.jpg\",\"datePublished\":\"2019-01-18T08:15:15+00:00\",\"dateModified\":\"2020-08-06T09:53:24+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/#\\\/schema\\\/person\\\/63a68934672db675ff0cd80d066510c2\"},\"description\":\"In this tutorial, you will learn about the Numbers wrapper class. You will learn about boxing and unboxing as well as various methods of the number class\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/14-java-the-number-class\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/14-java-the-number-class\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/14-java-the-number-class\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/wp-content\\\/uploads\\\/sites\\\/9\\\/2019\\\/01\\\/Number-Class-in-Java.jpg\",\"contentUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/wp-content\\\/uploads\\\/sites\\\/9\\\/2019\\\/01\\\/Number-Class-in-Java.jpg\",\"width\":963,\"height\":518,\"caption\":\"Number class\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/14-java-the-number-class\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java &#8211; The Number Class\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/#website\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/\",\"name\":\"Java Tutorials\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/#\\\/schema\\\/person\\\/63a68934672db675ff0cd80d066510c2\",\"name\":\"kindsonthegenius\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g\",\"caption\":\"kindsonthegenius\"},\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/author\\\/kindsonthegenius-2\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Java - The Number Class - Java Tutorials","description":"In this tutorial, you will learn about the Numbers wrapper class. You will learn about boxing and unboxing as well as various methods of the number 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:\/\/www.kindsonthegenius.com\/java\/14-java-the-number-class\/","og_locale":"en_US","og_type":"article","og_title":"Java - The Number Class - Java Tutorials","og_description":"In this tutorial, you will learn about the Numbers wrapper class. You will learn about boxing and unboxing as well as various methods of the number class","og_url":"https:\/\/www.kindsonthegenius.com\/java\/14-java-the-number-class\/","og_site_name":"Java Tutorials","article_published_time":"2019-01-18T08:15:15+00:00","article_modified_time":"2020-08-06T09:53:24+00:00","og_image":[{"width":963,"height":518,"url":"https:\/\/www.kindsonthegenius.com\/java\/wp-content\/uploads\/sites\/9\/2019\/01\/Number-Class-in-Java.jpg","type":"image\/jpeg"}],"author":"kindsonthegenius","twitter_card":"summary_large_image","twitter_misc":{"Written by":"kindsonthegenius","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.kindsonthegenius.com\/java\/14-java-the-number-class\/#article","isPartOf":{"@id":"https:\/\/www.kindsonthegenius.com\/java\/14-java-the-number-class\/"},"author":{"name":"kindsonthegenius","@id":"https:\/\/www.kindsonthegenius.com\/java\/#\/schema\/person\/63a68934672db675ff0cd80d066510c2"},"headline":"Java &#8211; The Number Class","datePublished":"2019-01-18T08:15:15+00:00","dateModified":"2020-08-06T09:53:24+00:00","mainEntityOfPage":{"@id":"https:\/\/www.kindsonthegenius.com\/java\/14-java-the-number-class\/"},"wordCount":638,"commentCount":0,"image":{"@id":"https:\/\/www.kindsonthegenius.com\/java\/14-java-the-number-class\/#primaryimage"},"thumbnailUrl":"https:\/\/www.kindsonthegenius.com\/java\/wp-content\/uploads\/sites\/9\/2019\/01\/Number-Class-in-Java.jpg","articleSection":["Java Tutorial"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.kindsonthegenius.com\/java\/14-java-the-number-class\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.kindsonthegenius.com\/java\/14-java-the-number-class\/","url":"https:\/\/www.kindsonthegenius.com\/java\/14-java-the-number-class\/","name":"Java - The Number Class - Java Tutorials","isPartOf":{"@id":"https:\/\/www.kindsonthegenius.com\/java\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.kindsonthegenius.com\/java\/14-java-the-number-class\/#primaryimage"},"image":{"@id":"https:\/\/www.kindsonthegenius.com\/java\/14-java-the-number-class\/#primaryimage"},"thumbnailUrl":"https:\/\/www.kindsonthegenius.com\/java\/wp-content\/uploads\/sites\/9\/2019\/01\/Number-Class-in-Java.jpg","datePublished":"2019-01-18T08:15:15+00:00","dateModified":"2020-08-06T09:53:24+00:00","author":{"@id":"https:\/\/www.kindsonthegenius.com\/java\/#\/schema\/person\/63a68934672db675ff0cd80d066510c2"},"description":"In this tutorial, you will learn about the Numbers wrapper class. You will learn about boxing and unboxing as well as various methods of the number class","breadcrumb":{"@id":"https:\/\/www.kindsonthegenius.com\/java\/14-java-the-number-class\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.kindsonthegenius.com\/java\/14-java-the-number-class\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.kindsonthegenius.com\/java\/14-java-the-number-class\/#primaryimage","url":"https:\/\/www.kindsonthegenius.com\/java\/wp-content\/uploads\/sites\/9\/2019\/01\/Number-Class-in-Java.jpg","contentUrl":"https:\/\/www.kindsonthegenius.com\/java\/wp-content\/uploads\/sites\/9\/2019\/01\/Number-Class-in-Java.jpg","width":963,"height":518,"caption":"Number class"},{"@type":"BreadcrumbList","@id":"https:\/\/www.kindsonthegenius.com\/java\/14-java-the-number-class\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.kindsonthegenius.com\/java\/"},{"@type":"ListItem","position":2,"name":"Java &#8211; The Number Class"}]},{"@type":"WebSite","@id":"https:\/\/www.kindsonthegenius.com\/java\/#website","url":"https:\/\/www.kindsonthegenius.com\/java\/","name":"Java Tutorials","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.kindsonthegenius.com\/java\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.kindsonthegenius.com\/java\/#\/schema\/person\/63a68934672db675ff0cd80d066510c2","name":"kindsonthegenius","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g","caption":"kindsonthegenius"},"url":"https:\/\/www.kindsonthegenius.com\/java\/author\/kindsonthegenius-2\/"}]}},"_links":{"self":[{"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/posts\/86","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/users\/395"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/comments?post=86"}],"version-history":[{"count":6,"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/posts\/86\/revisions"}],"predecessor-version":[{"id":203,"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/posts\/86\/revisions\/203"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/media\/97"}],"wp:attachment":[{"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/media?parent=86"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/categories?post=86"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/tags?post=86"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}