The compiler wouldn't evaluate the condition in the if clause. So all it sees is that the initialization is done conditionally and thats the reason for the error.
I dont quite agree with Krishna ...
If the code is modified to include an else along with the if then it works just fine !
which means that the compiler checks to see if the variable y is initialized or not...In your case...If x were not 5 thn y would never be initialized. So if u have an else clause, it makes sure tht y is initialized all the time.
Also if u have something like this..
if(true)
y = 0;
then the compiler does not complain..
[ August 10, 2004: Message edited by: Murtuza Akhtari ]