{"id":13,"date":"2009-06-07T16:01:48","date_gmt":"2009-06-07T14:01:48","guid":{"rendered":"http:\/\/dirk.forbiddendream.be\/?p=13"},"modified":"2016-01-07T10:50:33","modified_gmt":"2016-01-07T10:50:33","slug":"final-objects","status":"publish","type":"post","link":"https:\/\/dirk.schuermans.me\/?p=13","title":{"rendered":"Final objects"},"content":{"rendered":"<p>One thing i&#8217;ve noticed when you declare an instance of an object as final,<br \/>\nis that you can still modify the object properties, even while the object is declared as final.<\/p>\n<p>Example:<\/p>\n<pre name=\"code\" class=\"java\">\/\/ Final object example\r\nfinal Foo myFoo = new Foo();\r\n\r\n\/\/This will output the default value, let's say 0\r\nSystem.out.println(myFoo.getValue());\r\n\r\n\/\/ Set the value to 20\r\nmyFoo.setValue(20);\r\n\r\n\/\/This will output the new value, 20, with no compilation errors\r\nSystem.out.println(myFoo.getValue()); <\/pre>\n<p>One thing you&#8217;ll have to keep in mind is that when you&#8217;d like to re-declare the object:<\/p>\n<pre name=\"code\" class=\"java\">\/\/ Re-declare the object\r\nmyFoo = new Foo();<\/pre>\n<p>This won&#8217;t work, it&#8217;ll throw errors since myFoo was final after all \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One thing i&#8217;ve noticed when you declare an instance of an object as final, is that you can still modify the object properties, even while the object is declared as final. Example: \/\/ Final object example final Foo myFoo = new Foo(); \/\/This will output the default value, let&#8217;s say 0 System.out.println(myFoo.getValue()); \/\/ Set the &hellip; <a href=\"https:\/\/dirk.schuermans.me\/?p=13\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Final objects<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[38],"tags":[],"_links":{"self":[{"href":"https:\/\/dirk.schuermans.me\/index.php?rest_route=\/wp\/v2\/posts\/13"}],"collection":[{"href":"https:\/\/dirk.schuermans.me\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dirk.schuermans.me\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dirk.schuermans.me\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dirk.schuermans.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=13"}],"version-history":[{"count":3,"href":"https:\/\/dirk.schuermans.me\/index.php?rest_route=\/wp\/v2\/posts\/13\/revisions"}],"predecessor-version":[{"id":792,"href":"https:\/\/dirk.schuermans.me\/index.php?rest_route=\/wp\/v2\/posts\/13\/revisions\/792"}],"wp:attachment":[{"href":"https:\/\/dirk.schuermans.me\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=13"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dirk.schuermans.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=13"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dirk.schuermans.me\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=13"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}