Cannot be resolved to a variable error in Eclipse

Try this…

The problem here is about the scope of the variable.

i should be declared of type int, which is local to the run() method instead of n, as n is another local variable in fibNumber() method.

i and n are totally in different scope and are invisible to each other.

for (int i = 1; i <= 15; i++){

        println("F" + i + " = " + fibNumber(i));  // i should be here.


Leave a Comment