Garmaine Staff asked 2 years ago
This question already has answers here:
http://stackoverflow.com//questions/25706216/what-does-a-cannot-find-symbol-or-cannot-resolve-symbol-error-mean”>What does a “Cannot find symbol” or “Cannot resolve symbol” error mean? (13 answers)
Closed 5 hours ago.

Here is the simple code

package first;

public class DowhileLoops {

    public static void main(String[] args) {
        // TODO Auto-generated method stub

        do {
            int i = 1;
            i++;
            System.out.println("my loop is working ");

        }while(5 > i);
    }
}

Here is the Error

Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
i cannot be resolved to a variable
at todowhileloops/first.DowhileLoops.main(DowhileLoops.java:15)

I khow that the variable must be defined outside instead of inside the loop but i want to know whyyyyy… please help and vote the question.