{"id":87391,"date":"2020-04-22T15:00:00","date_gmt":"2020-04-22T12:00:00","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=87391"},"modified":"2020-04-27T17:25:22","modified_gmt":"2020-04-27T14:25:22","slug":"java-data-types-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/java-data-types-example\/","title":{"rendered":"Java Data Types Example"},"content":{"rendered":"<p>In this article, we will learn about the Java data types. We will see examples with Java Primitive Data Types, like Number, Floating-point, Boolean, and Character, and examples with non-primitive Types, like String, Object, Interface, and Array.<\/p>\n<div class=\"toc\">\n<h3>Table Of Contents<\/h3>\n<dl>\n<dt><a href=\"#introduction\">1. Introduction<\/a><\/dt>\n<dt><a href=\"#data_type\">2. Data Type<\/a><\/dt>\n<dd>\n<dl>\n<dt><a href=\"#primitive_data_type\">2.1 Primitive Data Type<\/a><\/dt>\n<dd>\n<dl>\n<dt><a href=\"#number\">2.1.1 Number<\/a><\/dt>\n<dt><a href=\"#floating_point\">2.1.2 Floating-point<\/a><\/dt>\n<dt><a href=\"#boolean\">2.1.3 Boolean<\/a><\/dt>\n<dt><a href=\"#character\">2.1.4 Character<\/a><\/dt>\n<\/dl>\n<\/dd>\n<dt><a href=\"#non_primitive_data_type\">2.2 Non-Primitive Data Type<\/a><\/dt>\n<dd>\n<dl>\n<dt><a href=\"#string\">2.2.1 String<\/a><\/dt>\n<dt><a href=\"#object\">2.2.2 Object<\/a><\/dt>\n<dt><a href=\"#interface\">2.2.3 Interface<\/a><\/dt>\n<dt><a href=\"#array\">2.2.4 Array<\/a><\/dt>\n<\/dl>\n<\/dd>\n<\/dl>\n<\/dd>\n<dt><a href=\"#conclusion\">3. Java Data Types &#8211; Summary<\/a><\/dt>\n<dt><a href=\"#download\">4. Download the source code<\/a><\/dt>\n<\/dl>\n<\/div>\n<h2><a name=\"introduction\"><\/a>1. Introduction<\/h2>\n<p>The Java programming language is statically-typed, which means that all variables must first be declared before they can be used. This involves stating the variable&#8217;s type and name.<\/p>\n<pre class=\"brush:java\">int age = 10;<\/pre>\n<p>Doing so tells your program that a field named <em>age<\/em> exists, holds numerical data, and has an initial value of <em>10<\/em>. A variable&#8217;s data type determines the values it may contain, plus the operations that may be performed on it.<\/p>\n<h2><a name=\"data_type\"><\/a>2. Data Type<\/h2>\n<p>In this section, we will look into the different types of <code>data types<\/code> available in Java. In Java, <code>Data Types<\/code> are divided into two broad categories: <code>Primitive data types<\/code> and <code>Non-primitive data types<\/code>.<\/p>\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"820\" height=\"375\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-21-at-22.10.41.jpg\" alt=\"Java Data Types\" class=\"wp-image-88223\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-21-at-22.10.41.jpg 820w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-21-at-22.10.41-300x137.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/04\/Screenshot-2020-04-21-at-22.10.41-768x351.jpg 768w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><figcaption>Java Data Types<\/figcaption><\/figure>\n<h3 class=\"wp-block-heading\"><a name=\"primitive_data_type\"><\/a>2.1 Primitive Data Type<\/h3>\n<p>A primitive type is predefined by the language and is named by a reserved keyword. It specifies the size and type of variable values, and it has no additional methods. Primitive values do not share state with other primitive values. There are eight primitive <code>data types<\/code> in Java: <code>byte<\/code>, <code>short<\/code>, <code>int<\/code>, <code>long<\/code>, <code>float<\/code>, <code>double<\/code>, <code>boolean<\/code> and <code>char<\/code><\/p>\n<figure class=\"wp-block-table is-style-stripes\">\n<table>\n<tbody>\n<tr>\n<td><strong>Data Type<\/strong><\/td>\n<td><strong>Size<\/strong><\/td>\n<td><strong>Description<\/strong><\/td>\n<td><strong>Default Value<\/strong><\/td>\n<\/tr>\n<tr>\n<td>boolean<\/td>\n<td>1 bit<\/td>\n<td>Has values as <code>true<\/code> or <code>false<\/code><\/td>\n<td>false<\/td>\n<\/tr>\n<tr>\n<td>byte<\/td>\n<td>1 byte<\/td>\n<td>Stores whole numbers from -128 to 127<\/td>\n<td>0<\/td>\n<\/tr>\n<tr>\n<td>char<\/td>\n<td>2 bytes<\/td>\n<td>Stores a single character\/letter or ASCII values<\/td>\n<td>&#8216;\\u0000&#8217;<\/td>\n<\/tr>\n<tr>\n<td>short<\/td>\n<td>2 bytes<\/td>\n<td>Stores whole numbers from -32,768 to 32,767<\/td>\n<td>0<\/td>\n<\/tr>\n<tr>\n<td>int<\/td>\n<td>4 bytes<\/td>\n<td>Stores whole numbers from -2,147,483,648 to 2,147,483,647<\/td>\n<td>0<\/td>\n<\/tr>\n<tr>\n<td>long<\/td>\n<td>8 bytes<\/td>\n<td>Stores whole numbers from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807<\/td>\n<td>oL<\/td>\n<\/tr>\n<tr>\n<td>float<\/td>\n<td>4 bytes<\/td>\n<td>Stores fractional numbers. Sufficient for storing 6 to 7 decimal digits<\/td>\n<td>0.0f<\/td>\n<\/tr>\n<tr>\n<td>double<\/td>\n<td>8 bytes<\/td>\n<td>Stores fractional numbers. Sufficient for storing 15 decimal digits<\/td>\n<td>0.0d<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<h4 class=\"wp-block-heading\"><a name=\"number\"><\/a>2.1.1 Numbers<\/h4>\n<p>Primitive number types are divided into two groups:<\/p>\n<p><strong>Integer<\/strong> types stores whole numbers, positive or negative (such as 999 or -999), without decimals. Valid types are <code>byte<\/code>, <code>short<\/code>, <code>int<\/code> and <code>long<\/code>. Which type you should use, depends on the numeric value.<\/p>\n<p><b>Floating-point<\/b> types represent numbers with a fractional part, containing one or more decimals. There are two types: <code>float<\/code> and <code>double<\/code>.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p><strong>Byte<\/strong><\/p>\n<p>The&nbsp;<code>byte<\/code>&nbsp;data type is an 8-bit signed two&#8217;s complement integer. The <code>byte<\/code> data type can store whole numbers from <code>-128<\/code> to <code>127<\/code>. This can be used instead of <code>int<\/code> or other integer types to save memory when you are certain that the value will be within <code>-128<\/code> and <code>127<\/code>. The <code>byte<\/code> data type is used to save memory in large arrays where the memory saving is most required. It saves space because a byte is 4 times smaller than an integer<\/p>\n<pre class=\"brush:java\">byte myByte = 125;\nSystem.out.println(myByte);<\/pre>\n<p><strong>Short<\/strong> <\/p>\n<p>The <code>short<\/code> data type is a 16-bit signed two&#8217;s complement integer. Its value-range lies between <code>-32,768<\/code> to <code>32,767<\/code> (inclusive). Its default value is 0. The <code>short<\/code> data type can also be used to save memory just like <code>byte<\/code> data type. A short data type is 2 times smaller than an integer.<\/p>\n<pre class=\"brush:java\">short myShort = -32765;\nSystem.out.println(myShort);<\/pre>\n<p><strong>Int<\/strong><\/p>\n<p>The <code>int<\/code> data type is a 32-bit signed two&#8217;s complement integer. Its value-range lies between <code>- 2,147,483,648<\/code> (<code>-2^31<\/code>) to <code>2,147,483,647<\/code> (<code>2^31 -1<\/code>) (inclusive). Its default value is 0.The <code>int<\/code> data type is generally used as a default data type for integral values unless if there is no problem about memory.<\/p>\n<pre class=\"brush:java\">int myInt = 2147483647;\nSystem.out.println(myInt);<\/pre>\n<p><strong>Long<\/strong><br \/>The <code>long<\/code> data type can store whole numbers from <code>-9223372036854775808<\/code> to <code>9223372036854775807<\/code>. This is used when <code>int<\/code> is not large enough to store the value. Note that you should end the value with an <code>L<\/code>.<\/p>\n<pre class=\"brush:java\">long myLong = -9223372036854775808L;\nSystem.out.println(myLong);<\/pre>\n<h4 class=\"wp-block-heading\"><a name=\"floating_point\"><\/a>2.1.2 Floating-point<\/h4>\n<p>Use floating-point type data-type when the number is in decimal.<\/p>\n<p><strong>Float<\/strong><br \/>The <code>float<\/code> data type can store fractional numbers from <code>3.4e\u2212038<\/code> to <code>3.4e+038<\/code>. Note that you should end the value with an <code>f<\/code>:<\/p>\n<pre class=\"brush:java\">float myFloat = 1234567.75f;\nSystem.out.println(myFloat);<\/pre>\n<p><strong>Double<\/strong><br \/>The <code>double<\/code> data type can store fractional numbers from <code>1.7e\u2212308<\/code> to <code>1.7e+308<\/code>. Note that you should end the value with a <code>d<\/code>:<\/p>\n<pre class=\"brush:java\">double myDouble = 123456789012.75234d;\nSystem.out.println(myDouble);<\/pre>\n<p>Running the above code will output <code>1.2345678901275233E11<\/code>. The precision of a floating point value indicates how many digits the value can have after the decimal point. The precision of <code>float<\/code> is only six or seven decimal digits, while <code>double<\/code> variables have a precision of about 15 digits. Therefore it is safer to use double for most calculations.<\/p>\n<h4 class=\"wp-block-heading\"><a name=\"boolean\"><\/a>2.1.3 Boolean<\/h4>\n<p>A boolean data type is declared with the boolean keyword and can only take the values true or false. They are mostly used for conditional testing.<\/p>\n<pre class=\"brush:java\">boolean myBoolean = true;\nSystem.out.println(myBoolean);<\/pre>\n<h4 class=\"wp-block-heading\"><a name=\"character\"><\/a>2.1.4 Character<\/h4>\n<p>The <code>char<\/code> data type is used to store a single character. The character must be surrounded by single quotes, like &#8216;A&#8217; or &#8216;a&#8217;.You can also use ASCII values to display certain characters:<\/p>\n<pre class=\"brush:java\">char myChar = 'a';\nSystem.out.println(myChar);\nchar A = 65;\nSystem.out.println(A);<\/pre>\n<h3 class=\"wp-block-heading\"><a name=\"non_primitive_data_type\"><\/a>2.2 Non-Primitive Data Type<\/h3>\n<p>Non-primitive data types are called reference types because they refer to objects. The main difference between primitive and non-primitive data types are:<\/p>\n<ul class=\"wp-block-list\">\n<li>Primitive types are predefined (already defined) in Java. Non-primitive types are created by the programmer and is not defined by Java (except for String).<\/li>\n<li> Non-primitive types can be used to call methods to perform certain operations, while primitive types cannot.<\/li>\n<li> A primitive type has always a value, while non-primitive types can be <code>null<\/code>.<\/li>\n<li> A primitive type starts with a lowercase letter, while non-primitive types starts with an uppercase letter.<\/li>\n<li> The size of a primitive type depends on the data type, while non-primitive types have all the same size.<\/li>\n<\/ul>\n<h4 class=\"wp-block-heading\"><a name=\"string\"><\/a>2.2.1 String<\/h4>\n<p>The <code>String<\/code> data type is used to store a sequence of characters (text). String values must be surrounded by double quotes:<\/p>\n<pre class=\"brush:java\">String str = \"Java Code Geeks\";\nSystem.out.println(str);<\/pre>\n<p>A <code>String<\/code> in Java is actually a&nbsp;non-primitive&nbsp;data type, because it refers to an object. The <code>String<\/code> object has methods that are used to perform certain operations on strings. Strings are constant; their values cannot be changed after they are created.<\/p>\n<p>The Java language provides special support for the string concatenation operator (<code> + <\/code>), and for conversion of other objects to strings. <code>String<\/code> concatenation is implemented through the <code>StringBuilder<\/code>(or <code>StringBuffer<\/code>) class and its <code>append<\/code> method. String conversions are implemented through the method <code>toString<\/code>, defined by <code>Object<\/code> and inherited by all classes in Java.<\/p>\n<h4 class=\"wp-block-heading\"><a name=\"object\"><\/a>2.2.2 Object<\/h4>\n<p>Java objects are analogous to objects in the real world. In the real world, an object is an entity having both state and behaviour. It can be physical (tangible) , such as a house, car, etc., or logical (intangible), such as a Customer. In Java, all objects are intangible in the sense they only exist as a collection of data and programming in computer memory. A Java object is a representation of an entity and an implementation of its behaviours.<\/p>\n<p>All Java objects have three characteristics:<\/p>\n<ul class=\"wp-block-list\">\n<li><strong>Identity<\/strong> is a unique ID used to identify the specific object from all other objects of the same kind. This ID is used internally by the Java system to reference and track an object and is not directly changeable by the programmer or user.<\/li>\n<li><strong>State<\/strong> is determined by a group of data values associated with the object.<\/li>\n<li><strong>Behavior<\/strong> is a series of methods that implement the object&#8217;s functionality.<\/li>\n<\/ul>\n<p>Objects and classes are intertwined. A class is a description of a group of objects that have common properties and behaviour. It&#8217;s a template or blueprint from which specific objects are created. An object is a specific instance of class with its own state.<\/p>\n<h4 class=\"wp-block-heading\"><a name=\"interface\"><\/a>2.2.3 Interface<\/h4>\n<p>Interface is a way of achieving abstraction in Java. To access the interface methods, the interface must be <em>implemented<\/em> by another class with the <code>implements<\/code> keyword.<\/p>\n<p>Like abstract classes, interfaces cannot be used to create objects. On implementation of an interface, you must override all of its methods. Interface methods are by default abstract and public. Interface attributes are by default public, static and final. An interface cannot contain a constructor (as it cannot be used to create objects).<\/p>\n<p>Java does not support &#8220;multiple inheritance&#8221; (a class can only inherit from one superclass). However, it can be achieved with interfaces, because the class can implement multiple interfaces.<\/p>\n<h4 class=\"wp-block-heading\"><a name=\"array\"><\/a>2.2.4 Array<\/h4>\n<p>Arrays are used to store multiple values in a single variable, instead of declaring separate variables for each value. To declare an array, define the variable type with square brackets:<\/p>\n<pre class=\"brush:java\">int[] arrays = new int[10];<\/pre>\n<p>The above declared variable <code>arrays<\/code> can hold 10 values of <code>int<\/code> type.<\/p>\n<pre class=\"brush:java\">int[] initializedArrays = new int[]{50, 2, 44};<\/pre>\n<p>The above code initializes the array while declaring it. Please note that we don&#8217;t explicitly provide the size in the second case as it is determined based on the number of values provided in the curly braces. You access an array element by referring to the index number:<\/p>\n<pre class=\"brush:java\">System.out.println(\"Second element in the array: \" + initializedArrays[1]);<\/pre>\n<p>The above code will print the second element of the array.  To change the value of a specific element, refer to the index number:<\/p>\n<pre class=\"brush:java\">int[] initializedArrays = new int[]{50, 2, 44};\nSystem.out.println(\"Second element in the array: \" + initializedArrays[1]);\ninitializedArrays[1] = 100;\nSystem.out.println(\"New Second element in the array: \" + initializedArrays[1]);<\/pre>\n<h2 class=\"wp-block-heading\"><a name=\"conclusion\"><\/a>3. Java Data Types &#8211; Summary<\/h2>\n<p>In Java, <code>Data Types<\/code> are divided into two broad categories Primitive types and <code>Non-primitive data types<\/code>. In this article, we discussed the various <code>data types<\/code> used in Java programming language. First, we looked into the primitive data types and discussed what their minimum and maximum values can be and what they are used for. Then we looked at some of the most commonly used non-primitive data types e.g. String, Object, etc.<\/p>\n<h2 class=\"wp-block-heading\"><a name=\"download\"><\/a>4. Download the source code<\/h2>\n<div class=\"download\"><strong>Download<\/strong><br \/>You can download the full source code of this example here: <a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/04\/java-data-types.zip\"><strong>Java Data Types Example<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we will learn about the Java data types. We will see examples with Java Primitive Data Types, like Number, Floating-point, Boolean, and Character, and examples with non-primitive Types, like String, Object, Interface, and Array. Table Of Contents 1. Introduction 2. Data Type 2.1 Primitive Data Type 2.1.1 Number 2.1.2 Floating-point 2.1.3 Boolean &hellip;<\/p>\n","protected":false},"author":34,"featured_media":1204,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-87391","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-core-java"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Java Data Types Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"In this article, we will learn about the Java data types. We will see examples with Java Primitive Data Types, like Number, Floating-point, Boolean, and\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/java-data-types-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java Data Types Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"In this article, we will learn about the Java data types. We will see examples with Java Primitive Data Types, like Number, Floating-point, Boolean, and\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/java-data-types-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2020-04-22T12:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-04-27T14:25:22+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Mohammad Meraj Zia\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mohammad Meraj Zia\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-data-types-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-data-types-example\/\"},\"author\":{\"name\":\"Mohammad Meraj Zia\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/442b4f9b8a4aa7e12376464fc354f8ed\"},\"headline\":\"Java Data Types Example\",\"datePublished\":\"2020-04-22T12:00:00+00:00\",\"dateModified\":\"2020-04-27T14:25:22+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-data-types-example\/\"},\"wordCount\":1443,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-data-types-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"articleSection\":[\"Core Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-data-types-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-data-types-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/java-data-types-example\/\",\"name\":\"Java Data Types Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-data-types-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-data-types-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"datePublished\":\"2020-04-22T12:00:00+00:00\",\"dateModified\":\"2020-04-27T14:25:22+00:00\",\"description\":\"In this article, we will learn about the Java data types. We will see examples with Java Primitive Data Types, like Number, Floating-point, Boolean, and\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-data-types-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-data-types-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-data-types-example\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"Bipartite Graph\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-data-types-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Core Java\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Java Data Types Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/442b4f9b8a4aa7e12376464fc354f8ed\",\"name\":\"Mohammad Meraj Zia\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/06\/IMG-20200324-WA0003-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/06\/IMG-20200324-WA0003-96x96.jpg\",\"caption\":\"Mohammad Meraj Zia\"},\"description\":\"Senior Java Developer\",\"sameAs\":[\"http:\/\/www.javacodegeeks.com\/\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/mohammad-zia\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Java Data Types Example - Java Code Geeks","description":"In this article, we will learn about the Java data types. We will see examples with Java Primitive Data Types, like Number, Floating-point, Boolean, and","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:\/\/examples.javacodegeeks.com\/java-data-types-example\/","og_locale":"en_US","og_type":"article","og_title":"Java Data Types Example - Java Code Geeks","og_description":"In this article, we will learn about the Java data types. We will see examples with Java Primitive Data Types, like Number, Floating-point, Boolean, and","og_url":"https:\/\/examples.javacodegeeks.com\/java-data-types-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2020-04-22T12:00:00+00:00","article_modified_time":"2020-04-27T14:25:22+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","type":"image\/jpeg"}],"author":"Mohammad Meraj Zia","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Mohammad Meraj Zia","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/java-data-types-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/java-data-types-example\/"},"author":{"name":"Mohammad Meraj Zia","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/442b4f9b8a4aa7e12376464fc354f8ed"},"headline":"Java Data Types Example","datePublished":"2020-04-22T12:00:00+00:00","dateModified":"2020-04-27T14:25:22+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-data-types-example\/"},"wordCount":1443,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-data-types-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","articleSection":["Core Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/java-data-types-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/java-data-types-example\/","url":"https:\/\/examples.javacodegeeks.com\/java-data-types-example\/","name":"Java Data Types Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-data-types-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-data-types-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","datePublished":"2020-04-22T12:00:00+00:00","dateModified":"2020-04-27T14:25:22+00:00","description":"In this article, we will learn about the Java data types. We will see examples with Java Primitive Data Types, like Number, Floating-point, Boolean, and","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/java-data-types-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/java-data-types-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/java-data-types-example\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","width":150,"height":150,"caption":"Bipartite Graph"},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/java-data-types-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java Development","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/"},{"@type":"ListItem","position":3,"name":"Core Java","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/"},{"@type":"ListItem","position":4,"name":"Java Data Types Example"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/442b4f9b8a4aa7e12376464fc354f8ed","name":"Mohammad Meraj Zia","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/06\/IMG-20200324-WA0003-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2020\/06\/IMG-20200324-WA0003-96x96.jpg","caption":"Mohammad Meraj Zia"},"description":"Senior Java Developer","sameAs":["http:\/\/www.javacodegeeks.com\/"],"url":"https:\/\/examples.javacodegeeks.com\/author\/mohammad-zia\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/87391","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/34"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=87391"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/87391\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/1204"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=87391"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=87391"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=87391"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}