[Solved] Can anyone show me why does it give me variable not initialized? [closed]


d1 is not initialized in the else block and in only in the if or else if blocks, so if all the statements in if() and else if() blocks are false then the controller comes to the else block, where d1 is still not initialized. so when you try to access it inside system.out.println(), the compiler rightly throws the error. you may want to initialize the value to 0 in the beginning.

1

solved Can anyone show me why does it give me variable not initialized? [closed]