Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • 4
    "Java has no free() or delete operators, so it has to rely on tracking variable scope to find out when variables are no longer used (together with references to these variables of cause)." - While true, this not relevant. C and C++ have free / delete operators respectively, and yet the equivalent C / C++ code to your examples would be illegal. C and C++ blocks limit the scope of variables just like in Java. In fact, this is true for most "block structured" languages. Commented Nov 1, 2017 at 13:41
  • 1
    The better solution for code that assigns a different value on every branch is to use a blank final variable declaration. Commented Apr 3, 2018 at 13:43