Powered by Ajaxy
Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Java: How to use forin loop with Collection

Java: How to use forin  loop with Collection
{filelink=4413}

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class ForInDemo {
  public static void main(String[] args) {
    List listMot = new ArrayList();
    Set wordset = new HashSet();
    for(String word : args)
{
      System.out.print(word + " ");
      listMot.add(word);
      wordset.add(word);
    }
    System.out.println();
    System.out.println("View the list of words'listMot' ");
     // forin loop
    for(Object word : listMot) {
      System.out.print((String)word + " ");
    }
    System.out.println();
    // // forin loop
    for(Object word : wordset) {
      System.out.print((String)word + " ");
    }
  }
}

Users who found this page were searching for:

  • forin loop

No comments yet.

Leave a Comment