{"id":76541,"date":"2020-02-18T09:55:16","date_gmt":"2020-02-18T04:25:16","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=76541"},"modified":"2020-02-18T09:55:16","modified_gmt":"2020-02-18T04:25:16","slug":"java-number","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/java-number\/","title":{"rendered":"Java Number &#8211; Explore the Different Number Methods with Syntax!"},"content":{"rendered":"<p>We use numbers in our everyday life since childhood, whether it be some calculation, score or something to measure, numbers make it all possible.<\/p>\n<p>Numbers are something that can never leave our side, whether we like it or not. Similarly, it isn&#8217;t possible that we learn Java without learning about Numbers.<\/p>\n<p>The most basic data type of any computer language is number. Generally while working with numbers in Java, we use primitive <em><strong>data types<\/strong><\/em> which are byte, short, int, long, float and double.<\/p>\n<p>As we know that these data types are just data values and not class objects, sometimes we need numerical values in the form of objects. Java solves this problem by providing <strong>wrapper classes<\/strong>.<\/p>\n<p>Java provides six numeric wrapper subclasses under the abstract class Number which is present in java.lang package.<\/p>\n<p><strong>Wrapper classes<\/strong>\u00a0are part of Java\u2019s standard library <strong>java.lang<\/strong>, which converts the primitive data types into an object.<\/p>\n<p>These wrapper subclasses come under the umbrella of abstract class Number. These six wrapper classes which provide additional power to numbers in Java are:<\/p>\n<ul>\n<li>Integer<\/li>\n<li>Short<\/li>\n<li>Byte<\/li>\n<li>Float<\/li>\n<li>Long<\/li>\n<li>Double<\/li>\n<\/ul>\n<p>The following diagram shows a hierarchical view of these wrapper classes:<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/02\/wrapper-class-in-java.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-76682\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/02\/wrapper-class-in-java.jpg\" alt=\"wrapper class java\" width=\"594\" height=\"576\" \/><\/a><\/p>\n<h3>Java Number Class<\/h3>\n<p>In this article, we will discuss the <strong>Number Class<\/strong> in Java which wraps the value of numerical primitive data types into their corresponding objects. We will cover all the subclasses under this superclass Number.<\/p>\n<p>The following table shows all the numeric data types with their corresponding wrapper class:<\/p>\n<table class=\"tv-table-center\">\n<tbody>\n<tr>\n<td><b><i>Numeric Datatype<\/i><\/b><\/td>\n<td><b><i>Wrapper Class<\/i><\/b><\/td>\n<\/tr>\n<tr>\n<td>byte<\/td>\n<td>Byte<\/td>\n<\/tr>\n<tr>\n<td>short<\/td>\n<td>Short<\/td>\n<\/tr>\n<tr>\n<td>int<\/td>\n<td>Integer<\/td>\n<\/tr>\n<tr>\n<td>long<\/td>\n<td>Long<\/td>\n<\/tr>\n<tr>\n<td>float<\/td>\n<td>Float<\/td>\n<\/tr>\n<tr>\n<td>double<\/td>\n<td>Double<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>Autoboxing and Unboxing<\/h3>\n<p>The Java compiler automatically converts the numeric data types into an object of the respective wrapper class. This process of converting primitive data type into an object is called <strong>autoboxing<\/strong> and, the reverse process, that is, converting the object into primitive data types is called <strong>unboxing.<\/strong><\/p>\n<p>For example, converting an \u2018int\u2019 into an object of \u2018Integer\u2019 and \u2018double\u2019 into an object of \u2018Double\u2019 is called Autoboxing. While converting the object of \u2018Integer\u2019 and \u2018Double\u2019 class into \u2018int\u2019 and \u2018double\u2019 data type respectively is called Unboxing.<\/p>\n<p><strong>Code to understand Autoboxing and Unboxing:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.TechVidvan.JavaNumbers;\npublic class AutoandUnBoxing\n{\n  public static void main(String args[])\n  {\n      Integer operand1 = 5; \/\/ Autoboxing: boxes int datatype to an \tInteger object\n      Double operand2 = 44.9; \/\/ Autoboxing: boxes double datatype to an Double object\n      operand1 = operand1 + 10; \/\/Unboxing: unboxes the Integer to a int\n      operand2 = operand2 + 30; \/\/Unboxing: unboxes the Double to a double\n      System.out.println(\"Value of the operand1 is: \"+operand1);\n      System.out.println(\"Value of the operand2 is: \"+operand2);\n  }\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">Value of the operand1 is: 15<br \/>\nValue of the operand2 is: 74.9<\/div>\n<h3>Methods of Java Number Class<\/h3>\n<p>The Number Class comes with several methods that are useful for performing operations on numbers. We will discuss each of these methods in detail with the help of examples:<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/02\/methods-of-java-number-class.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-76683\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/02\/methods-of-java-number-class.jpg\" alt=\"java number methods\" width=\"802\" height=\"420\" \/><\/a><\/p>\n<h4>1. type typeValue() method<\/h4>\n<p>This method converts the value of the object of Number class to the specified primitive number data type and returns it. Here type represents primitive number data types: byte, short, int, long, float, double.<\/p>\n<p><strong>Syntax of typeValue() method for each data type:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">byte byteValue()<\/pre>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">short shortValue()<\/pre>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">int intValue()<\/pre>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">long longValue()\n<\/pre>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">float floatValue()<\/pre>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">double doubleValue()<\/pre>\n<p><strong>Code to illustrate typeValueMethod:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.TechVidvan.JavaNumbers;\npublic class typeValueMethodDemo\n{\n  public static void main(String[] args)\n  {\n\n  \/\/ Creating a Double Class object with value \"45.13627\"\n    Double doubleVariable = new Double(\"45.13627\");\n\n  \/\/ Converting this Double(Number) object to different primitive data types\n    byte byteVariable = doubleVariable.byteValue();\n    short shortVariable = doubleVariable.shortValue();\n    int integerVariable = doubleVariable.intValue();\n    long longVariable = doubleVariable.longValue();\n    float floatVariable = doubleVariable.floatValue();\n    double doubleVariableObject = doubleVariable.doubleValue();\n\n  \/\/Printing the converted variables\n    System.out.println(\"Converting double into byte: \" + byteVariable);\n    System.out.println(\"Converting double into short: \" + shortVariable);\n    System.out.println(\"Converting double into int: \" + integerVariable);\n    System.out.println(\"Converting double into long: \" + longVariable);\n    System.out.println(\"Converting double into float: \" + floatVariable);\n    System.out.println(\"Converting double into Double object: \" + doubleVariableObject);\n  }\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">Converting double into byte: 45<br \/>\nConverting double into short: 45<br \/>\nConverting double into int: 45<br \/>\nConverting double into long: 45<br \/>\nConverting double into float: 45.13627<br \/>\nConverting double into Double-object: 45.13627<\/div>\n<p><em><strong>Note:<\/strong> There may be a possible loss of precision while conversion. For example, we can note that the fraction part(\u201c.13627\u201d) has been left out while converting the Double-object into int data type.<\/em><\/p>\n<h4>2. int compareTo() method<\/h4>\n<p>This method compares the input argument with the Number object. It returns 1 (positive number) if the value of Number object is greater than the argument, -1 (negative number) if it is less than the value of argument and 0 if it is equal to the argument.<\/p>\n<p>But both the argument and the number should be of the same type, then only they can be compared. The reference type can be a byte, double, float, long, or short.<\/p>\n<p><strong>Syntax of compareTo() method:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">public int compareTo( NumberSubClass referenceName )\nSubClassObject.compareTo(valueToBeCompared)<\/pre>\n<p><strong>Code to illustrate compareTo() method:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.TechVidvan.JavaNumbers;\npublic class CompareToMethodDemo\n{\n  public static void main(String[] args)\n  {\n      \/\/ creating an Double Class object with value \"12.55\"\n      Double doubleObject = 12.55;\n    \n      \/\/initializing double variables \n      double comparisonValue1 = 8.66;\ndouble comparisonValue2 = 12.55;\ndouble comparisonValue3 = 15.98;\n    \n      \/\/ comparing value of doubleObject\nSystem.out.println(\"Comparing 12.55 with 37.5:\");\n\n\/\/we can directly pass the value of argument\nSystem.out.println(doubleObject.compareTo(37.5));\n\n      System.out.println(\"Comparing 12.55 with 6.66:\");\n      System.out.println(doubleObject.compareTo(comparisonValue1));\n      System.out.println(\"Comparing 12.55 with 12.55:\");\n      System.out.println(doubleObject.compareTo(comparisonValue2));\n      System.out.println(\"Comparing 12.55 with 15.98:\");\n      System.out.println(doubleObject.compareTo(comparisonValue3));\n}\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">Comparing 12.55 with 37.5:<br \/>\n-1<br \/>\nComparing 12.55 with 6.66:<br \/>\n1<br \/>\nComparing 12.55 with 12.55:<br \/>\n0<br \/>\nComparing 12.55 with 15.98:<br \/>\n-1<\/div>\n<h4>3. boolean equals(Object object) method<\/h4>\n<p>This method checks whether the Number object is equal to the argument (also of Number Type). Both Number object and argument may be of different types. It returns true if the values are equal, otherwise, it returns false.<\/p>\n<p><strong>Syntax of equals() method:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">public boolean equals(Object object)\nobject1.equals(object2);<\/pre>\n<p><strong>Code to illustrate equals() method:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.TechVidvan.JavaNumbers;\npublic class EqualsMethodDemo\n{\npublic static void main(String[] args)\n{\n  \/\/ creating three Short Class objects\n  Short shortObject1 = 15;\n  Short shortObject2 = 4;\n  Short shortObject3 = 4;\n\n  \/\/ creating an Integer Class object\n  Integer integerObject1 = 15;\n\n  \/\/ creating an Double Class object\n  Double doubleObject1= 28.65;\n  System.out.println(shortObject1.equals(shortObject2));\n  System.out.println(shortObject1.equals(integerObject1));\n  System.out.println(shortObject2.equals(shortObject3));\n  System.out.println(shortObject1.equals(doubleObject1));\n}\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">false<br \/>\nfalse<br \/>\ntrue<br \/>\nfalse<\/div>\n<p><em><strong>Note:<\/strong> See even if the numeric values of Integer and Short object are the same (that is, 15), the method returns false because their types are not the same.<\/em><\/p>\n<h4>4. int parseInt() method<\/h4>\n<p>While working with strings, sometimes we need to convert a number represented in the form of string into an integer type. The method parseInt() is generally used to convert String to Integer in Java.<\/p>\n<p>We can also pass the argument radix in this method which represents decimal, octal, or hexadecimal type as output. This method returns the primitive data type of a String.<\/p>\n<p><strong>Syntax of parseInt() method::<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">static Integer parseInt(int i)\nstatic Integer parseInt(String s)\nstatic Integer parseInt(String s, int radix)<\/pre>\n<p><strong>Code to illustrate parseInt() method:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.TechVidvan.JavaNumbers;\npublic class ParseIntMethodDemo\n{\n  public static void main(String[] args)\n  {\n    \/\/ parsing different strings\n    int intVariable1 = Integer.parseInt(\"567\",8); \t\t\t\t\/\/string to octal conversion\n    int intVariable2 = Integer.parseInt(\"567\"); \/\/String to int\n    int intVariable3 = Integer.parseInt(\"-AC\", 16); \/\/string to hexadecimal\n    long longVariable = Long.parseLong(\"3615345721\",10); \/\/string to decimal \n    short shortVariable = Short.parseShort(\"216\",8); \/\/ String to octal conversion\n    double doubleVariable = Double.parseDouble(\"216\");\/\/String to double\n\n    System.out.println(intVariable1);\n    System.out.println(intVariable2);\n    System.out.println(intVariable3);\n    System.out.println(longVariable);\n    System.out.println(shortVariable);\n    System.out.println(doubleVariable);\n\n   \/\/ NumberFormatException will occur because \"TechVidvan\" is not a parsable string\n    int intVariable4 = Integer.parseInt(\"TechVidvan\",16);\n\n   \/\/ NumberFormatException will occur here(for octal(8),allowed digits are [0-7])\n    int intVariable5 = Integer.parseInt(\"978\",8);\n  }\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">375<br \/>\n567<br \/>\n-172<br \/>\n3615345721<br \/>\n142<br \/>\n216.0<br \/>\nException in thread &#8220;main&#8221; java.lang.NumberFormatException: For input string: &#8220;TechVidvan&#8221; under radix 2<br \/>\nat java.base\/java.lang.NumberFormatException.forInputString(NumberFormatException.java:68)<br \/>\nat java.base\/java.lang.Integer.parseInt(Integer.java:658)<br \/>\nat project1\/com.TechVidvan.JavaNumbers.ParseIntMethodDemo.main(ParseIntMethodDemo.java:23)<\/div>\n<h4>5. String toString() method<\/h4>\n<p>This method is used to get the String object representation of any Number object. This method takes a primitive data type as an argument and returns a String object representing the primitive data type value.<\/p>\n<p>There are three variants of this method-<\/p>\n<ul>\n<li>toBinaryString(int i)<\/li>\n<li>toHexString(int i)<\/li>\n<li>toOctalString(int i)<\/li>\n<\/ul>\n<p><strong>Syntax of toString() method:<\/strong><\/p>\n<ol>\n<li>String toString()<\/li>\n<li>String toString(int integerObject)<\/li>\n<\/ol>\n<p><strong>Code to illustrate toString() method:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.TechVidvan.JavaNumbers;\npublic class ToStringMethodDemo\n{\n  public static void main(String args[])\n  {\n    \/\/ creating integer object\n    Integer integerObject = 25;\n    System.out.println(integerObject.toString());\n    System.out.println(Integer.toString(72)); \/\/integer to string conversion\n\n    \/\/integer to binary string conversion\n    System.out.println(Integer.toBinaryString(367));\n\n    \/\/integer to hex string conversion\n    System.out.println(Integer.toHexString(367));\n\n    \/\/integer to an octal string conversion\n    System.out.println(Integer.toOctalString(367)); }\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">25<br \/>\n72<br \/>\n101101111<br \/>\n16f<br \/>\n557<\/div>\n<h4>6. Integer valueOf() method<\/h4>\n<p>The valueOf method converts the value of an argument into the relevant Number Object. The argument can be any numeric primitive data type or String.<\/p>\n<p>This method is a static method that can be called directly through the Integer class. The method can take two arguments, where one is a String or a primitive data type and the other is a radix.<\/p>\n<p><strong>Syntax of valueOf() method::<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">Integer valueOf(int i)\nInteger valueOf(String stringValue)\nInteger valueOf(String stringValue, int radix)<\/pre>\n<p><strong>Code to illustrate valueOf() method:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.TechVidvan.JavaNumbers;\npublic class ValueOfMethodDemo\n{\n  public static void main(String args[])\n  {\n    \/\/ demonstrating valueOf(int integerObject) method\n    Integer integerObject1 =Integer.valueOf(922);\n    Double doubleObject = Double.valueOf(5.9);\n    Float floatObject = Float.valueOf(80);\n    System.out.println(integerObject1);\n    System.out.println(doubleObject);\n    System.out.println(floatObject);\n\n    \/\/ demonstrating valueOf(String stringValue) method\n    Integer integerObject2 = Integer.valueOf(\"444\",16);\n    Integer integerObject3 = Integer.valueOf(\"-953\");\n    System.out.println(integerObject2);\n    System.out.println(\"\\n\" +integerObject3);\n\n    \/\/ demonstrating valueOf(String stringValue,int radix) method\n    Integer integerObject4 = Integer.valueOf(\"333\",8);\n    Long longObject = Long.valueOf(\"51688245\",16);\n\n    System.out.println(\"\\n\" +integerObject4);\n    System.out.println(longObject);\n  }\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">922<br \/>\n5.9<br \/>\n80.01092<br \/>\n-953219<br \/>\n1365803589<\/div>\n<p>Apart from these methods, there are some more methods in Java.lang.Math, that are helpful for performing various operations on numbers. We will briefly look at each of these methods through the following table.<\/p>\n<table class=\"tv-table-center\">\n<tbody>\n<tr>\n<td><b>Method<\/b><\/td>\n<td><b>Description<\/b><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">abs()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns the absolute value of the argument.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">ceil()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns the smallest integer that is greater than or equal to the argument in double format.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">floor()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns the largest integer that is less than or equal to the argument in double format.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">min()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns the smaller of the two arguments.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">max()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns the larger of the two arguments.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">exp()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns e, to the power of the argument.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">log()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns the natural logarithm of the argument.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">pow()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns the value of the first argument raised to the power of the second argument.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">sqrt()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns the square root of the argument.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">random()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns a random number<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">sin()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns the sine of the specified double value.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">cos()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns the cosine of the specified double value.<\/span><\/td>\n<\/tr>\n<tr>\n<td><span style=\"font-weight: 400\">tan()<\/span><\/td>\n<td><span style=\"font-weight: 400\">Returns the tangent of the specified double value.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>Summary<\/h3>\n<p>Here we came to the end of our tutorial on Java Numbers. In this article, we learned about the abstract class number along with its subclasses in Java. We also discussed the different methods associated with the Number class with the help of their syntax and code.<\/p>\n<p>I hope this article will help you to understand the complex codes related to numbers in Java.<\/p>\n<p>Thank you for reading our article. Do share your feedback through the comment section below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We use numbers in our everyday life since childhood, whether it be some calculation, score or something to measure, numbers make it all possible. Numbers are something that can never leave our side, whether&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":76683,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[183],"tags":[1760,1761,1762,1763,1764,1765,1766,1767],"class_list":["post-76541","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","tag-autoboxing-in-java","tag-java-number-class","tag-java-number-examples","tag-java-numbers","tag-methods-in-java-numbers","tag-numbers-in-java","tag-unboxing-in-java","tag-what-is-java-number"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Java Number - Explore the Different Number Methods with Syntax! - TechVidvan<\/title>\n<meta name=\"description\" content=\"Explore in detail the concept of Java Number &amp; learn the 6 different methods of number in Java explained with the help of syntax that will help you further in your Java programming.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/java-number\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java Number - Explore the Different Number Methods with Syntax! - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Explore in detail the concept of Java Number &amp; learn the 6 different methods of number in Java explained with the help of syntax that will help you further in your Java programming.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/java-number\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-02-18T04:25:16+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/02\/methods-of-java-number-class.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"802\" \/>\n\t<meta property=\"og:image:height\" content=\"420\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Java Number - Explore the Different Number Methods with Syntax! - TechVidvan","description":"Explore in detail the concept of Java Number & learn the 6 different methods of number in Java explained with the help of syntax that will help you further in your Java programming.","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:\/\/techvidvan.com\/tutorials\/java-number\/","og_locale":"en_US","og_type":"article","og_title":"Java Number - Explore the Different Number Methods with Syntax! - TechVidvan","og_description":"Explore in detail the concept of Java Number & learn the 6 different methods of number in Java explained with the help of syntax that will help you further in your Java programming.","og_url":"https:\/\/techvidvan.com\/tutorials\/java-number\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2020-02-18T04:25:16+00:00","og_image":[{"width":802,"height":420,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/02\/methods-of-java-number-class.jpg","type":"image\/jpeg"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/java-number\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-number\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Java Number &#8211; Explore the Different Number Methods with Syntax!","datePublished":"2020-02-18T04:25:16+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-number\/"},"wordCount":1214,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-number\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/02\/methods-of-java-number-class.jpg","keywords":["Autoboxing in Java","Java Number Class","Java Number examples","java numbers","Methods in Java Numbers","numbers in java","Unboxing in Java","What is Java Number"],"articleSection":["Java Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/java-number\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/java-number\/","url":"https:\/\/techvidvan.com\/tutorials\/java-number\/","name":"Java Number - Explore the Different Number Methods with Syntax! - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-number\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-number\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/02\/methods-of-java-number-class.jpg","datePublished":"2020-02-18T04:25:16+00:00","description":"Explore in detail the concept of Java Number & learn the 6 different methods of number in Java explained with the help of syntax that will help you further in your Java programming.","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/java-number\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/java-number\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/java-number\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/02\/methods-of-java-number-class.jpg","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/02\/methods-of-java-number-class.jpg","width":802,"height":420,"caption":"java number methods"},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/java-number\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Java Number &#8211; Explore the Different Number Methods with Syntax!"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/76541","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=76541"}],"version-history":[{"count":0,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/76541\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/76683"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=76541"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=76541"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=76541"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}