I am learning java as well android. Almost everything that we can perform by while loop those things we can do in for loop.
I found a simple condition where using w
int counter = 0;
while (counter < 10) {
//do some task
if(some condition){
break;
}
}
useTheCounter(counter); // method which use that value of counter do some other task
Hi I repeat your code because it is incorrect. You forget to increase your counter so it will remains on 0
int counter = 0;
while (counter < 10) {
//do some task
if(some condition){
break;
}
counter++;
}
useTheCounter(counter); // method which use that value of counter do some other task