+ 7
Variables are only initialized by default if they are either instance variables or static. Observe the following: public class AClass{ boolean a; void assumeCalled(){ boolean b; System.out.print(a); // ok, false System.out.print(b); // illegal } } There's a good explanation here on c# (which would be the same reasons as java) http://stackoverflow.com/questions/1542824/initialization-of-instance-fields-vs-local-variables/1542851#1542851 Now that I think of it, I wonder how many challenge questions ignore the illegal rule. 😂
7th Apr 2017, 4:55 PM
Rrestoring faith
Rrestoring faith - avatar