Exemple de la Boucle ‘forEach’ sur une collection

Author:


{filelink=4404}

import java.util.Collection;
import java.util.List;
import java.util.ArrayList;

public class ForeachDemo {
  static void iterate(Collection c) {
      for (String s : c)
      System.out.println(s);
  }
  public static void main(String args[]) {
    List l = new ArrayList();
    l.add("Toronto");
    l.add("Paris");
    iterate(l);
  }
}

Leave a Reply

Your email address will not be published. Required fields are marked *