{"id":4920,"date":"2014-03-30T16:55:58","date_gmt":"2014-03-30T16:55:58","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/final-in-java-method-arguments-collection-of-common-programming-errors\/"},"modified":"2014-03-30T16:55:58","modified_gmt":"2014-03-30T16:55:58","slug":"final-in-java-method-arguments-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/final-in-java-method-arguments-collection-of-common-programming-errors\/","title":{"rendered":"final in java method arguments-Collection of common programming errors"},"content":{"rendered":"<p>It doesn&#8217;t make a difference at runtime. This is provable in the most conclusive way: adding the <code>final<\/code> modifier doesn&#8217;t even change the compiled bytecode!<\/p>\n<h2>FinalParam.java (before)<\/h2>\n<pre><code>class FinalParam {\n   public static void main(String[] args) {\n      System.out.println(java.util.Arrays.toString(args));\n   }\n}\n\n$ javac -version\njavac 1.7.0_15\n$ javac FinalParam.java\n$ md5sum FinalParam.class\n7ca43ea68179f6191d5bf1de7ba21945\n$ rm FinalParam.class\n<\/code><\/pre>\n<p>FinalParam.java (after)<\/p>\n<pre><code>class FinalParam {\n   public static void main(final String[] args) {\n      System.out.println(java.util.Arrays.toString(args));\n   }\n}\n\n$ javac FinalParam.java\n$ md5sum FinalParam.class\n7ca43ea68179f6191d5bf1de7ba21945\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>It doesn&#8217;t make a difference at runtime. This is provable in the most conclusive way: adding the final modifier doesn&#8217;t even change the compiled bytecode! FinalParam.java (before) class FinalParam { public static void main(String[] args) { System.out.println(java.util.Arrays.toString(args)); } } $ javac -version javac 1.7.0_15 $ javac FinalParam.java $ md5sum FinalParam.class 7ca43ea68179f6191d5bf1de7ba21945 $ rm FinalParam.class FinalParam.java [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4920","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4920","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4920"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4920\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4920"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4920"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4920"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}