Garmaine Staff asked 2 years ago
This question already has answers here:”>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;
            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(

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.