for(int i = 0; i < array.length; i++)Ou
{
System.out.println(array[i]);
}
for(String value : array)The second version of the for-each loop works for arrays and collections. Most loops can be done with the for-each loop as long as you don't need to know the current position in the array. If you need to know the index or position, use the first version.
{
System.out.println(value);
}
int index = 0;
while(index < array.length)
{
String value;
value = array[index];
System.out.println(value);
index++;
}
Please disable your ad blocker and refresh the window to use this website.