class returntest { public static void main(String...args) { int a; System.out.println(a);
I get a compiler error (obviously) on line 1, stating that the variable may not be initialized.
I know that all elements of an int array are initialized by default to 0 (so that line 2 compiles successfully), but my question is why the compiler can not apply the same logic (from 0 to all ints) to a regular (not an array) int variables.
Is there any restriction that prevents the compiler from doing this?
source share