{"id":5421,"date":"2023-09-23T11:52:28","date_gmt":"2023-09-23T10:52:28","guid":{"rendered":"https:\/\/www.baeldung.com\/java-value-based-classes"},"modified":"2023-09-23T11:52:28","modified_gmt":"2023-09-23T10:52:28","slug":"value-based-classes-in-java","status":"publish","type":"post","link":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/2023\/09\/23\/value-based-classes-in-java\/","title":{"rendered":"Value-Based Classes in Java"},"content":{"rendered":"<p><img src=\"https:\/\/www.baeldung.com\/wp-content\/uploads\/2021\/09\/Java-4-Featured-1024x536.png\" class=\"webfeedsFeaturedVisual wp-post-image\" alt=\"\" decoding=\"async\" style=\"float: left; margin-right: 5px;\" loading=\"lazy\" srcset=\"https:\/\/www.baeldung.com\/wp-content\/uploads\/2021\/09\/Java-4-Featured-1024x536.png 1024w, https:\/\/www.baeldung.com\/wp-content\/uploads\/2021\/09\/Java-4-Featured-300x157.png 300w, https:\/\/www.baeldung.com\/wp-content\/uploads\/2021\/09\/Java-4-Featured-768x402.png 768w, https:\/\/www.baeldung.com\/wp-content\/uploads\/2021\/09\/Java-4-Featured-100x52.png 100w, https:\/\/www.baeldung.com\/wp-content\/uploads\/2021\/09\/Java-4-Featured.png 1200w\" sizes=\"(max-width: 580px) 100vw, 580px\" \/><\/p>\n<h2 id=\"bd-introduction\" data-id=\"introduction\">1. Introduction<\/h2>\n<div class=\"bd-anchor\" id=\"introduction\"><\/div>\n<p>In this tutorial, we&#8217;ll talk about a very interesting feature that Project Valhalla brings to the Java ecosystem, Value-based Classes. Value-based classes were introduced in Java 8 and have gone through major refactors and enhancements in later releases.<\/p>\n<h2 id=\"bd-value-based-classes\" data-id=\"value-based-classes\">2. Value-based Classes<\/h2>\n<div class=\"bd-anchor\" id=\"value-based-classes\"><\/div>\n<h3 id=\"bd-1-project-valhalla\" data-id=\"1-project-valhalla\">2.1. Project Valhalla<\/h3>\n<div class=\"bd-anchor\" id=\"1-project-valhalla\"><\/div>\n<p><a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/java-valhalla-project\">Project Valhalla<\/a> is an experimental project by OpenJDK to add new features and capabilities to Java. The primary goal of this initiative is to add improved support for value types, generic specialization, and performance improvements while maintaining complete backward compatibility.<\/p>\n<p>Value-based classes are one of the features introduced by Project Valhalla to introduce primitive, immutable values to the Java language without the added overhead that traditional object-oriented classes bring.<\/p>\n<h3 id=\"bd-2-primitives-and-value-types\" data-id=\"2-primitives-and-value-types\">2.2. Primitives and Value-Types<\/h3>\n<div class=\"bd-anchor\" id=\"2-primitives-and-value-types\"><\/div>\n<p>Before we come to the formal definition of value-based classes, let&#8217;s look at two important semantics in Java &#8211; primitives and value types.<\/p>\n<p><strong><a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/java-primitives\">Primitive<\/a> data types, or primitives, in Java, are simple data types that represent a single value and are not objects. Java provides eight such primitive data types: <em>byte<\/em>, <em>short<\/em>, <em>int<\/em>, <em>long<\/em>, <em>float<\/em>, <em>double<\/em>, <em>char,<\/em> and <em>boolean<\/em>. While these are simple types, Java provides <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/java-wrapper-classes\">wrapper<\/a> classes for each of these for us to interact with them in an object-oriented way.<\/strong><\/p>\n<p>It is also important to remember that Java performs auto-boxing and unboxing automatically to convert between the object and primitive type efficiently:<\/p>\n<pre><code class=\"language-java\">int primitive_a = 125;\r\nInteger obj_a = 125; \/\/ this is autoboxed\r\nAssert.assertSame(primitive_a, obj_a);<\/code><\/pre>\n<p><strong>Primitive types live on the stack memory, while the objects that we use in our code live on the heap memory.<\/strong><\/p>\n<p>Project Valhalla introduced a new type in the Java ecosystem that is somewhat between an object and a primitive, and it is termed a value-type. Value types<strong> are immutable types, and they do not have any identity.<\/strong> These value types also do not support inheritance.<\/p>\n<p>Value types are not addressed by their reference but by their values, just like primitives.<\/p>\n<h3 id=\"bd-3-value-based-classes\" data-id=\"3-value-based-classes\">2.3. Value-Based Classes<\/h3>\n<div class=\"bd-anchor\" id=\"3-value-based-classes\"><\/div>\n<p>Value-based classes are classes that are designed to behave like and encapsulate <em>value-type<\/em>s in Java. The JVM can freely switch between value types and its value-based class, much like auto-boxing and unboxing. Value-based classes are hence, identity free, for the same reason.<\/p>\n<h2 id=\"bd-properties-of-value-based-classes\" data-id=\"properties-of-value-based-classes\">3. Properties of Value-Based Classes<\/h2>\n<div class=\"bd-anchor\" id=\"properties-of-value-based-classes\"><\/div>\n<p>Value-based classes are classes that represent simple immutable values. A Value-based class has several properties that can be categorized into some general themes.<\/p>\n<h3 id=\"bd-1-immutability\" data-id=\"1-immutability\">3.1. Immutability<\/h3>\n<div class=\"bd-anchor\" id=\"1-immutability\"><\/div>\n<p>Value-based classes are meant to represent immutable data, similar to primitives like <em>int,<\/em> and have the following characteristics:<\/p>\n<ul>\n<li>A value-based class is always <em>final<\/em><\/li>\n<li>It contains only the <em>final<\/em> fields<\/li>\n<li>The class can extend the <em>Object <\/em>class or a hierarchy of abstract classes that declare no instance fields<\/li>\n<\/ul>\n<h3 id=\"bd-2-object-creation\" data-id=\"2-object-creation\">3.2. Object Creation<\/h3>\n<div class=\"bd-anchor\" id=\"2-object-creation\"><\/div>\n<p>Let&#8217;s understand how creating new objects of value-based classes works:<\/p>\n<ul>\n<li>The class does not declare any accessible constructor<\/li>\n<li>In case there are accessible constructors, they should be marked as deprecated for removal<\/li>\n<li>The class should be instantiated only through factory methods. The instance received from the factory may or may not be a new instance, and the calling code should not make any assumption about its identity<\/li>\n<\/ul>\n<h3 id=\"bd-3-identity-and-equals-hashcodetostring-methods\" data-id=\"3-identity-and-equals-hashcodetostring-methods\">3.3. Identity and <em>equals()<\/em>, <em>hashCode(),<\/em>\u00a0<em>toString() <\/em>Methods<\/h3>\n<div class=\"bd-anchor\" id=\"3-identity-and-equals-hashcodetostring-methods\"><\/div>\n<p>Value-based classes are identity-free. As they are still classes in Java, we need to understand how methods inherited from <em>Object\u00a0<\/em>class happens:<\/p>\n<ul>\n<li>The implementations of <em>equals()<\/em>, <em>hashCode(),<\/em> and <em>toString()<\/em> are defined solely based on the values of its instance members and not from their identities, nor any other instance&#8217;s state<\/li>\n<li>We consider two objects to be equal solely on the objects&#8217; <em>equals()<\/em> check and not on reference-based equality, i.e. ==<\/li>\n<li>We can use two equal objects interchangeably, and they should produce the same result on any computation or method invocation.<\/li>\n<\/ul>\n<h3 id=\"bd-4-some-additional-caveats\" data-id=\"4-some-additional-caveats\">3.4. Some Additional Caveats<\/h3>\n<div class=\"bd-anchor\" id=\"4-some-additional-caveats\"><\/div>\n<p>We should consider some additional limitations while working with value-based classes:<\/p>\n<ul>\n<li>Two objects, which are equal based on the <em>equals()<\/em> method, might be different objects in the JVM or the same<\/li>\n<li>We cannot ensure exclusive ownership of the <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/cs\/monitor\">monitor<\/a>, making instances unsuitable for <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/java-synchronized\">synchronization<\/a><\/li>\n<\/ul>\n<h2 id=\"bd-examples-of-value-based-classes\" data-id=\"examples-of-value-based-classes\">4. Examples of Value-Based Classes<\/h2>\n<div class=\"bd-anchor\" id=\"examples-of-value-based-classes\"><\/div>\n<h3 id=\"bd-1-value-based-classes-in-the-jdk\" data-id=\"1-value-based-classes-in-the-jdk\">4.1. Value-Based Classes in the JDK<\/h3>\n<div class=\"bd-anchor\" id=\"1-value-based-classes-in-the-jdk\"><\/div>\n<p>There are several classes in the JDK that follow the Value-based class specification.<\/p>\n<p>When it was first introduced, <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/java-optional\"><em>java.util.Optional<\/em><\/a> and the <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/java-8-date-time-intro\">DateTime<\/a> API (<em>java.time.LocalDateTime<\/em>)<em>\u00a0<\/em>were value-based classes. As of Java 16 and beyond, Java has defined all the wrapper classes of primitive types such as <em>Integer<\/em> and <em>Long<\/em> as value-based.<\/p>\n<p>These classes have the <em>@ValueBased<\/em> annotation from the <em>jdk.internal<\/em> package present:<\/p>\n<pre><code class=\"language-java\">@jdk.internal.ValueBased\r\npublic final class Integer extends Number implements Comparable&lt;Integer&gt;, Constable, ConstantDesc {\r\n    \/\/ Integer class in the JDK\r\n}<\/code><\/pre>\n<h3 id=\"bd-2-custom-value-based-class\" data-id=\"2-custom-value-based-class\">4.2. Custom Value-Based Class<\/h3>\n<div class=\"bd-anchor\" id=\"2-custom-value-based-class\"><\/div>\n<p>Let&#8217;s create our custom class which follows the value-based class specification defined above. For our example, let&#8217;s take a <em>Point\u00a0<\/em>class which identifies a point in 3D space. The class has 3 integer fields <em>x<\/em>, <em>y,<\/em> and <em>z<\/em>.<\/p>\n<p>We can argue that the <em>Point\u00a0<\/em>definition serves as a good candidate for a value-based class because a specific point in space is unique and can be referred to only by its value. It is constant and unambiguous, much like an integer of value 302.<\/p>\n<p>We&#8217;ll start by defining the class to be <em>final<\/em> and its attributes <em>x<\/em>, <em>y,<\/em> and<em> z<\/em> as final. Let&#8217;s also make the constructor private:<\/p>\n<pre><code class=\"language-java\">public final class Point {\r\n    private final int x;\r\n    private final int y;\r\n    private final int z;<\/code><\/pre>\n<pre><code class=\"language-java\">    \/\/ inaccessible constructor\r\n    private Point(int x, int y, int z) {\r\n        this.x = x;\r\n        this.y = y;\r\n        this.z = z;\r\n    }\r\n    \/\/ ...\r\n}<\/code><\/pre>\n<p>Now, let&#8217;s\u00a0have the <em>origin(0, 0, 0)<\/em> instance of the class created beforehand, and we return the same instance every time there is a call to create a point with <em>x = 0<\/em>, <em>y = 0,<\/em> and<em> z = 0:<\/em><\/p>\n<pre><code class=\"language-java\">private static Point ORIGIN = new Point(0, 0, 0);<\/code><\/pre>\n<p>We now need to provide an object creation mechanism in the form of a factory method:<\/p>\n<pre><code class=\"language-java\">public static Point valueOfPoint(int x, int y, int z) {\r\n    \/\/ returns a cached instance if it is the origin, or a new instance\r\n    if (isOrigin(x, y, z)) {\r\n        return ORIGIN;\r\n    }\r\n    return new Point(x, y, z);\r\n}\r\n\/\/ checking if a point is the origin\r\nprivate static boolean isOrigin(int x, int y, int z) {\r\n    return x == 0 &amp;&amp; y == 0 &amp;&amp; z == 0;\r\n}<\/code><\/pre>\n<p>The factory method <em>valueOfPoint() <\/em>could return a new instance or a cached one depending on the parameters. <strong>This forces the calling code not to make any assumption on the state of the object or compare references of two instances.\u00a0<\/strong><\/p>\n<p>Finally, we should define the <em>equals()<\/em> method based only on the values of instance fields:<\/p>\n<pre><code class=\"language-java\">@Override\r\npublic boolean equals(Object other) {\r\n    if (other == null || getClass() != other.getClass()) {\r\n        return false;\r\n    }\r\n    Point point = (Point) other;\r\n    return x == point.x &amp;&amp; y == point.y &amp;&amp; z == point.z;\r\n}\r\n@Override\r\npublic int hashCode() {\r\n    return Objects.hash(x, y, z);\r\n}<\/code><\/pre>\n<p>We now have a class <em>Point<\/em>, which can behave as a value-based class. We can put the <em>@ValueBased<\/em> annotation to the class after importing it from<em> jdk.internal<\/em> package. However, it is not mandatory for our case.<\/p>\n<p>Let&#8217;s now test that two instances of the same point in space denoted by (1,2,3) are equal:<\/p>\n<pre><code class=\"language-java\">@Test\r\npublic void givenValueBasedPoint_whenCompared_thenReturnEquals() {\r\n    Point p1 = Point.valueOfPoint(1,2,3);\r\n    Point p2 = Point.valueOfPoint(1,2,3);\r\n    Assert.assertEquals(p1, p2);\r\n}<\/code><\/pre>\n<p>Additionally, for the sake of this exercise, let&#8217;s also see that two instances, if compared by reference, are the same when two <em>origin<\/em> points are created:<\/p>\n<pre><code class=\"language-java\">@Test\r\npublic void givenValueBasedPoint_whenOrigin_thenReturnCachedInstance() {\r\n    Point p1 = Point.valueOfPoint(0, 0, 0);\r\n    Point p2 = Point.valueOfPoint(0, 0, 0);\r\n    \/\/ the following should not be assumed for value-based classes\r\n    Assert.assertTrue(p1 == p2);\r\n}<\/code><\/pre>\n<h2 id=\"bd-advantages-of-value-based-classes\" data-id=\"advantages-of-value-based-classes\">5. Advantages of Value-Based Classes<\/h2>\n<div class=\"bd-anchor\" id=\"advantages-of-value-based-classes\"><\/div>\n<p>Now that we know what value-based classes are and how we can define one, let&#8217;s understand why we might need value-based classes at all.<\/p>\n<p>Value-based classes being part of the Valhalla specification, are still in the experimental phase and continue to evolve. Therefore, the benefits of such classes may change over time.<\/p>\n<p>As of now, the most important benefit that comes out of using value-based classes is memory utilization. Value-based classes are more memory efficient as they do not have reference-based identity.<strong> Additionally, the JVM can reuse existing instances or create new ones based on the requirements, thereby reducing the memory footprint.<\/strong><\/p>\n<p><strong>Also, they do not require synchronization, increasing overall performance, especially in multithreaded applications.<\/strong><\/p>\n<h2 id=\"bd-difference-between-value-based-classes-and-other-types\" data-id=\"difference-between-value-based-classes-and-other-types\">6. Difference Between Value-Based Classes and Other Types<\/h2>\n<div class=\"bd-anchor\" id=\"difference-between-value-based-classes-and-other-types\"><\/div>\n<h3 id=\"bd-1-immutable-classes\" data-id=\"1-immutable-classes\">6.1. Immutable Classes<\/h3>\n<div class=\"bd-anchor\" id=\"1-immutable-classes\"><\/div>\n<p><a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/java-immutable-object\">Immutable<\/a> classes in Java share a lot of common ground with Value-based classes. Hence, it is very crucial to understand the differences between them.<\/p>\n<p>While value-based classes are new and part of an ongoing experimental feature, Immutable classes have been a core and integral part of the Java ecosystem for a long time. <strong>The <em>String<\/em> class, <em>Enums,<\/em> and wrapper classes in Java, such as the <em>Integer<\/em> class, are examples of immutable classes.<\/strong><\/p>\n<p><strong>Immutable classes are not identity-free like value-based classes.<\/strong> Instances of Immutable classes having the same state are distinct, and we can compare them based on reference equality. <strong>Instances of value-based classes do not have the notion of reference-based equality:<\/strong><\/p>\n<p><strong>Immutable classes are free to provide accessible constructors and can have multiple attributes and complex behaviors.<\/strong> However, value-based classes represent simple values and do not define complex behavior with dependent attributes.<\/p>\n<p><strong>Finally, we should note that value-based classes are, by definition, immutable but not vice-versa.<\/strong><\/p>\n<h3 id=\"bd-2-records\" data-id=\"2-records\">6.2. Records<\/h3>\n<div class=\"bd-anchor\" id=\"2-records\"><\/div>\n<p>Java introduced the notion of <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/java-record-keyword\"><em>Records<\/em><\/a> in Java 14 as an easy way to pass around immutable data objects. Records and value-based classes fulfill different purposes even if they seem similar in behavior and semantics.<\/p>\n<p><strong>The most noticeable distinction between records and value-based classes is that records have public constructors, while value-based classes lack them.<\/strong><\/p>\n<h2 id=\"bd-conclusion\" data-id=\"conclusion\">7. Conclusion<\/h2>\n<div class=\"bd-anchor\" id=\"conclusion\"><\/div>\n<p>In this article, we talked about value-based classes and the notion of value types in Java. We touched upon the important properties that value-based classes must abide by and the benefits they bring. We also discussed the differences between value-based classes and similar Java concepts, such as immutable classes and records.<\/p>\n<p>As always, the code snippets used in this article are available <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/github.com\/eugenp\/tutorials\/tree\/master\/core-java-modules\/core-java-16\">over on GitHub<\/a>.<\/p>\n<p><Img align=\"left\" border=\"0\" height=\"1\" width=\"1\" alt=\"\" style=\"border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;\" hspace=\"0\" src=\"https:\/\/feeds.feedblitz.com\/~\/i\/794523269\/0\/baeldung\"><\/p>\n<div style=\"clear:both;padding-top:0.2em;\"><a title=\"Like on Facebook\" href=\"https:\/\/feeds.feedblitz.com\/_\/28\/794523269\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/fblike20.png\" style=\"border:0;margin:0;padding:0;\"><\/a>&#160;<a title=\"Pin it!\" href=\"https:\/\/feeds.feedblitz.com\/_\/29\/794523269\/baeldung,https%3A%2F%2Fwww.baeldung.com%2Fwp-content%2Fuploads%2F2021%2F09%2FJava-4-Featured-1024x536.png\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/pinterest20.png\" style=\"border:0;margin:0;padding:0;\"><\/a>&#160;<a title=\"Tweet This\" href=\"https:\/\/feeds.feedblitz.com\/_\/24\/794523269\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/twitter20.png\" style=\"border:0;margin:0;padding:0;\"><\/a>&#160;<a title=\"Subscribe by email\" href=\"https:\/\/feeds.feedblitz.com\/_\/19\/794523269\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/email20.png\" style=\"border:0;margin:0;padding:0;\"><\/a>&#160;<a title=\"Subscribe by RSS\" href=\"https:\/\/feeds.feedblitz.com\/_\/20\/794523269\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/rss20.png\" style=\"border:0;margin:0;padding:0;\"><\/a>&#160;<a rel=\"NOFOLLOW\" title=\"View Comments\" href=\"https:\/\/www.baeldung.com\/java-value-based-classes#comments\"><img decoding=\"async\" height=\"20\" style=\"border:0;margin:0;padding:0;\" src=\"https:\/\/assets.feedblitz.com\/i\/comments20.png\"><\/a>&#160;<a title=\"Follow Comments via RSS\" href=\"https:\/\/www.baeldung.com\/java-value-based-classes\/feed\"><img decoding=\"async\" height=\"20\" style=\"border:0;margin:0;padding:0;\" src=\"https:\/\/assets.feedblitz.com\/i\/commentsrss20.png\"><\/a>&nbsp;<\/p>\n<div style=\"clear:left;\"><a rel=\"NOFOLLOW\" href=\"https:\/\/www.baeldung.com\/java-value-based-classes#comments\"><\/p>\n<h3>Comments<\/h3>\n<p><\/a><\/p>\n<ul>\n<li><a rel=\"NOFOLLOW\" href=\"https:\/\/www.baeldung.com\/java-value-based-classes#comment-14927\">In reply to fantaman.   Thanks, we&#8217;ll address these changes in &#8230;<\/a> <i>by Loredana Crusoveanu<\/i>\n<li><a rel=\"NOFOLLOW\" href=\"https:\/\/www.baeldung.com\/java-value-based-classes#comment-14921\">The example with Assert.assertSame(primitive_a, obj_a); is &#8230;<\/a> <i>by fantaman<\/i><\/ul>\n<\/div>\n<p>&#160;<\/p><\/div>\n\n<h2><b>Commercials Cooperation Advertisements:<\/b><\/h2>\r\n<p><br>(1) IT Teacher IT Freelance<br> <\/p>\r\n<a href=https:\/\/itteacheritfreelance.hk\/wordpress><img src=http:\/\/gamefootballmobileanimeiphone.com\/wp-content\/uploads\/2023\/09\/ITTeacherITFreelance-Website.png alt=IT\u96fb\u8166\u88dc\u7fd2 java\u88dc\u7fd2 \u70ba\u5927\u5bb6\u914d\u5c0d\u96fb\u8166\u88dc\u7fd2,IT freelance, \u79c1\u4eba\u8001\u5e2b, PHP\u88dc\u7fd2,CSS\u88dc\u7fd2,XML,Java\u88dc\u7fd2,MySQL\u88dc\u7fd2,graphic design\u88dc\u7fd2,\u4e2d\u5c0f\u5b78ICT\u88dc\u7fd2,\u4e00\u5c0d\u4e00\u79c1\u4eba\u88dc\u7fd2\u548cFreelance\u81ea\u7531\u5de5\u4f5c\u914d\u5c0d\u3002\/><\/a><p><a href=https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/findteacher>\u7acb\u523b\u8a3b\u518a\u53ca\u5831\u540d\u96fb\u8166\u88dc\u7fd2\u8ab2\u7a0b\u5427! <\/a><br>\r\n\r\n\u7535\u5b50\u8ba1\u7b97\u673a -\u6559\u80b2 -IT \u96fb\u8166\u73ed\u201d ( IT\u96fb\u8166\u88dc\u7fd2 ) \u63d0\u4f9b\u4e00\u500b\u65b9\u4fbf\u7684\u7535\u5b50\u8ba1\u7b97\u673a \u6559\u80b2\u5e73\u53f0, \u70ba\u5927\u5bb6\u914d\u5c0d\u4fe1\u606f\u6280\u672f, \u96fb\u8166 \u8001\u5e2b, IT freelance \u548c programming expert. \u8b93\u5927\u5bb6\u65b9\u4fbf\u5730\u5c31\u80fd\u627e\u5230\u5408\u9069\u7684\u96fb\u8166\u88dc\u7fd2, \u96fb\u8166\u73ed, \u5bb6\u6559, \u79c1\u4eba\u8001\u5e2b.  <br>\r\n\r\nWe are a education and information platform which you can find a IT private tutorial teacher or freelance. <br>\r\n\r\nAlso we provide different information about information technology, Computer, programming, mobile, Android, apple, game, movie, anime, animation\u2026 \r\n<\/p>\n<p><br>(2) ITSec<br> <\/p><a href=https:\/\/itsec.vip><img src=http:\/\/gamefootballmobileanimeiphone.com\/wp-content\/uploads\/2023\/09\/ITSec-Main-Promotion-Image.png alt= https:\/\/itsec.vip\/\r\nSecure Your Computers from Cyber Threats and mitigate risks with professional services to defend Hackers.  \r\nITSec provide IT Security and Compliance Services, including IT Compliance Services, Risk Assessment, IT Audit, Security Assessment and Audit, ISO 27001 Consulting and Certification, GDPR Compliance Services, Privacy Impact Assessment (PIA), Penetration test, Ethical Hacking, Vulnerabilities scan, IT Consulting, Data Privacy Consulting, Data Protection Services, Information Security Consulting, Cyber Security Consulting, Network Security Audit, Security Awareness Training.\/><\/a> \r\n<br><br> \r\n<p><a href=https:\/\/itsec.vip>www.ITSec.vip<\/a> <br> <br> \r\n<p><a href=https:\/\/sraa.com.hk>www.Sraa.com.hk<\/a> <br> <br> \r\n<p><a href=https:\/\/itsec.hk>www.ITSec.hk<\/a> <br> <br> \r\n<p><a href=https:\/\/penetrationtest.hk>www.Penetrationtest.hk<\/a> <br> <br> \r\n<p><a href=https:\/\/itseceu.uk>www.ITSeceu.uk<\/a> <br> <br> \r\nSecure Your Computers from Cyber Threats and mitigate risks with professional services to defend Hackers. <br><br>\r\nITSec provide IT Security and Compliance Services, including IT Compliance Services, Risk Assessment, IT Audit, Security Assessment and Audit, ISO 27001 Consulting and Certification, GDPR Compliance Services, Privacy Impact Assessment (PIA), Penetration test, Ethical Hacking, Vulnerabilities scan, IT Consulting, Data Privacy Consulting, Data Protection Services, Information Security Consulting, Cyber Security Consulting, Network Security Audit, Security Awareness Training. \r\n<br><br>Contact us right away. <br><br>Email (Prefer using email to contact us): <br>SalesExecutive@ITSec.vip<\/p>","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/www.baeldung.com\/wp-content\/uploads\/2021\/09\/Java-4-Featured-1024x536.png\" class=\"webfeedsFeaturedVisual wp-post-image\" alt=\"\" loading=\"lazy\"><\/p>\n<p>Explore value-based classes and the notion of value types in Java.<\/p>\n<div><a title=\"Like on Facebook\" href=\"https:\/\/feeds.feedblitz.com\/_\/28\/794523269\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/fblike20.png\"><\/a>\u00a0<a title=\"Pin it!\" href=\"https:\/\/feeds.feedblitz.com\/_\/29\/794523269\/baeldung,https%3A%2F%2Fwww.baeldung.com%2Fwp-content%2Fuploads%2F2021%2F09%2FJava-4-Featured-1024x536.png\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/pinterest20.png\"><\/a>\u00a0<a title=\"Tweet This\" href=\"https:\/\/feeds.feedblitz.com\/_\/24\/794523269\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/twitter20.png\"><\/a>\u00a0<a title=\"Subscribe by email\" href=\"https:\/\/feeds.feedblitz.com\/_\/19\/794523269\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/email20.png\"><\/a>\u00a0<a title=\"Subscribe by RSS\" href=\"https:\/\/feeds.feedblitz.com\/_\/20\/794523269\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/rss20.png\"><\/a>\u00a0<a rel=\"NOFOLLOW\" title=\"View Comments\" href=\"https:\/\/www.baeldung.com\/java-value-based-classes#comments\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/comments20.png\"><\/a>\u00a0<a title=\"Follow Comments via RSS\" href=\"https:\/\/www.baeldung.com\/java-value-based-classes\/feed\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/commentsrss20.png\"><\/a>\u00a0<\/p>\n<div><a rel=\"NOFOLLOW\" href=\"https:\/\/www.baeldung.com\/java-value-based-classes#comments\"><\/p>\n<h3>Comments<\/h3>\n<p><\/a><\/p>\n<ul>\n<li><a rel=\"NOFOLLOW\" href=\"https:\/\/www.baeldung.com\/java-value-based-classes#comment-14927\">In reply to fantaman.   Thanks, we&#8217;ll address these changes in &#8230;<\/a> <i>by Loredana Crusoveanu<\/i><\/li>\n<li><a rel=\"NOFOLLOW\" href=\"https:\/\/www.baeldung.com\/java-value-based-classes#comment-14921\">The example with Assert.assertSame(primitive_a, obj_a); is &#8230;<\/a> <i>by fantaman<\/i><\/li>\n<\/ul>\n<\/div>\n<p>\u00a0<\/p><\/div>\n","protected":false},"author":258,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"site-container-style":"default","site-container-layout":"default","site-sidebar-layout":"default","disable-article-header":"default","disable-site-header":"default","disable-site-footer":"default","disable-content-area-spacing":"default","footnotes":""},"categories":[22],"tags":[61,122,127,129,124,128,125,132,131,133,126,130,123,66,94,88,97,56,64,65,60,112,40,75,95,104,2476,33,120,105,101,98,115,30,29,41,86,70,69,68,72,71,26,118,108,87,46,55,48,52,54,51,50,83,62,58,57,2477,109,35,59,63,85,79,82,96,80,27,81,114,44,42,43,45,38,39,110,117,100,111,116,73,89,90,92,91,93,84,2478,78,37,102,34,36,77,67,74,99,113,119,28,121,32,47,49,53,103,31,76],"class_list":["post-5421","post","type-post","status-publish","format-standard","hentry","category-mobile","tag-airpods","tag-anime","tag-anime-characters","tag-anime-cosplay","tag-anime-edits","tag-anime-merchandise","tag-anime-movies","tag-anime-news","tag-anime-recommendations","tag-anime-reviews","tag-anime-series","tag-anime-streaming","tag-animes","tag-app-store","tag-app-store-samsung","tag-appgallery","tag-appgallery-oneplus","tag-apple","tag-apple-music","tag-apple-tv","tag-apple-watch","tag-bbc-sport","tag-best-mobile-games","tag-bixby","tag-bixby-xiaomi","tag-champions-league","tag-core-java","tag-cyberpunk","tag-cyberpunk-2077","tag-fantasy-football","tag-fifa","tag-football","tag-formula-1","tag-fortnite","tag-free-fire","tag-free-mobile-games","tag-freebuds-pro","tag-galaxy-a52","tag-galaxy-note-20","tag-galaxy-s21","tag-galaxy-watch-4","tag-galaxy-z-fold-3","tag-game","tag-games","tag-golf","tag-harmonyos","tag-how-to-backup-iphone","tag-how-to-factory-reset-iphone","tag-how-to-reset-iphone","tag-how-to-restore-iphone","tag-how-to-unlock-iphone","tag-how-to-unlock-iphone-5","tag-how-to-unlock-iphone-6","tag-huawei","tag-ios","tag-ipad","tag-iphone","tag-java-8","tag-live-soccer","tag-lol","tag-macbook","tag-macos","tag-mate-40-pro","tag-mi-11-lite","tag-mi-home-security-camera-basic-1080p","tag-mi-home-security-camera-basic-1080p-huawei","tag-mi-smart-band-6","tag-minecraft","tag-miui","tag-mlb-scores","tag-mobile-game-design","tag-mobile-game-development","tag-mobile-game-marketing","tag-mobile-game-monetization","tag-mobile-games","tag-mobile-gaming","tag-nba-scores","tag-nba-standings","tag-nfl","tag-nfl-scores","tag-nhl-scores","tag-one-ui","tag-oneplus","tag-oneplus-9-pro","tag-oneplus-buds-pro","tag-oneplus-nord-ce-5g","tag-oxygenos","tag-p40-pro-plus","tag-pattern","tag-poco-x3-pro","tag-pokemon","tag-premier-league","tag-pubg","tag-pubg-mobile","tag-redmi-note-10-pro","tag-samsung","tag-samsung-pay","tag-soccer","tag-sports","tag-steam","tag-steeam","tag-top-10-anime","tag-valorant","tag-when-do-the-iphone-7-come-out","tag-when-does-the-iphone-7-come-out","tag-when-is-the-iphone-7-coming-out","tag-world-cup","tag-xbox-series-x","tag-xiaomi"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/posts\/5421","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/users\/258"}],"replies":[{"embeddable":true,"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/comments?post=5421"}],"version-history":[{"count":1,"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/posts\/5421\/revisions"}],"predecessor-version":[{"id":5422,"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/posts\/5421\/revisions\/5422"}],"wp:attachment":[{"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/media?parent=5421"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/categories?post=5421"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/tags?post=5421"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}