I have a problem in when primitive data types initialized.
this will give the output or error as the variable y is getting read before being properly initialized.but in this below code the variables got initialized to 0,what is the difference here.can anyone explain?
The local variable should be initialized before they are used. The compiler will evaluate this value in all possible ways, that it thinks. And since we know that, in the above code, you initialized the variable y in all logically possible way with a poor if conditions, that's way it flags Compilation Error, saying that the variable y may not be initialized, if you change the as follows, you won't get Compilation Error. because you initialized the variable y in all the possible ways, that it thinks!
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|