Why "int foo = 0;" is pointless in variable declarations
From: What does the optimize switch do?
Part of the way down:
Part of the way down:
* We omit generating code for things like int foo = 0; because we know that the memory allocator will initialize fields to default values.The key there is that "the memory allocator will initialize fields to default values" ... see, there's really no point in setting fields to their default values, it's just code clutter. The compiler throws it away, and even if it didn't, the memory allocator would make it entirely pointless!

Leave a comment