Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.
Talk:Initializing local variables in Java
I more interested to know, why the Java compiler is not allowing to read the un initialized local variable? Where as it allows to read the un initialized instance variable by implicitly initializing to a default value.Good. I din't know that, even NOKIA has the developer community like IBM etc...
07:02, 22 March 2012 (EET)
It does not allow access to uninitialized local variables, because it is a rule of the Java language.
Because instance variables are automatically initialized, but local variables are not. If you read them, you would (as in a C program) read some random piece of information depending on what the memory was used for previously.
Why not auto-initialize locals?Because it takes time. It would add significantly to the overhead of invoking each method, making programs slower.
15:24, 9 February 2013 (EET)