Skip to content

Instantly share code, notes, and snippets.

@pravsingh
Last active October 16, 2017 22:54
Show Gist options
  • Save pravsingh/b94f9d40cbc0505cdf42144b85d4e79d to your computer and use it in GitHub Desktop.
Save pravsingh/b94f9d40cbc0505cdf42144b85d4e79d to your computer and use it in GitHub Desktop.
package com.designingmicroservices;
import java.util.ArrayList;
import java.util.Collection;
/**
*
* @author DesigningMicroservices.com
*
*/
public class CollectionsIteratorApplication {
public static void main(String[] args) {
Collection<String> collection1 = new ArrayList<String>();
collection1.add("zero");
collection1.add("one");
Collection<String> collection2 = new ArrayList<String>();
collection2.add("2.zero");
collection2.add("2.one");
collection2.add("2.two");
Collection<Collection<String>> col = new ArrayList<Collection<String>>();
col.add(collection1);
col.add(collection2);
CollectionsIterator<String> iterator = new CollectionsIterator<String>(col);
// while loop
while (iterator.hasNext()) {
System.out.println("value= " + iterator.next());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment