Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Exemple de la Boucle ‘forEach’ sur une collection


{filelink=4404}

import java.util.Collection;
import java.util.List;
import java.util.ArrayList;
<span id="more-950"></span>
public class ForeachDemo {
  static void iterate(Collection<String> c) {
      for (String s : c)
      System.out.println(s);
  }
  public static void main(String args[]) {
    List<String> l = new ArrayList<String>();
    l.add("Toronto");
    l.add("Paris");
    iterate(l);
  }
}