コレクションを反復処理し、拡張 for ループ (foreach 反復構文) に置換できる while ループを報告します。

例:


  Iterator it = c.iterator();
  while(it.hasNext()) {
    Object obj = it.next();
    System.out.println(obj);
  }

上のコードは下のコードに置換できます。


  for (Object obj : c) {
    System.out.println(obj);
  }