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);
}
You can also use the while:
int index = 0;
while(index < array.length)
{
String value;
value = array[index];
System.out.println(value);
index++;
}
Commentaires (0)
Laisser un commentaire
Connectez-vous pour commenter
Rejoignez la discussion et partagez vos connaissances avec la communauté
Chargement des commentaires...