public class HelloWorld{
public static void main(String []args){
String[] array = {"0","1","2","3","4","5"};
int i = 0;
for(String v : array){
if (i % 2 == 0){
System.out.println(v);
}
i++;
}
}
}
You are not using just the enhanced for loop in your code. You are using iteration variable as well. That is the whole point of this question. Enhanced for loop does not have an iteration variable.
If you like our products and services, please help us by posting your review here.
That is the whole point of this question. Enhanced for loop does not have an iteration variable. Otherwise, all loops are interchangeable. What you can do with one loop, you can do with another.
If you like our products and services, please help us by posting your review here.