You have putten num = 100 inside yout try block, the compiler assumes that an error may occur before num = 100 is reached. Thus, when you enter in the Catch bloch, for the compiler, he only sees int num which gives you the Variable not initialized error.