C
Chris Smith
Lasse said:No. That code, if executed as the body of a method, would never access
an uninitialized variable. If the compiler could know that, it could
omit the warning.
A large point of this thread, emphasized elsewhere but perhaps also
needed here, is that the compiler could *not* omit the error (not
warning) in that case. Not if it wanted to be a Java compiler, anyway.
The compiler could conceivable be made smart enough to determine with
certainty that the value would be initialized at that point... perhaps
that information might even be useful in generating a more helpful error
message... but a compliant Java compiler *will* reject that code with an
error message and *will* fail the compile.
Otherwise, it's broken. Not badly broken, but it is broken
nevertheless.
--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation