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.