// For a set or list
    for (Iterator it=collection.iterator(); it.hasNext(); ) {
        Object element = it.next();
    }
    
    // For keys of a map
    for (Iterator it=map.keySet().iterator(); it.hasNext(); ) {
        Object key = it.next();
    }
    
    // For values of a map
    for (Iterator it=map.values().iterator(); it.hasNext(); ) {
        Object value = it.next();
    }
    
    // For both the keys and values of a map
    for (Iterator it=map.entrySet().iterator(); it.hasNext(); ) {
        Map.Entry entry = (Map.Entry)it.next();
        Object key = entry.getKey();
        Object value = entry.getValue();
    }

// Create an array containing the elements in a list
    Object[] objectArray = list.toArray();
    MyClass[] array = (MyClass[])list.toArray(new MyClass[list.size()]);
   
    // Create an array containing the elements in a set
    Object[] objectArray = set.toArray();
    MyClass[] array = (MyClass[])set.toArray(new MyClass[set.size()]);