List of usage examples for java.util Collection iterator
Iterator<E> iterator();
From source file:Main.java
public static void main(String[] a) { HashMap<String, String> map = new HashMap<String, String>(); map.put("key1", "value1"); map.put("key2", "value2"); map.put("key3", "value3"); Collection set = map.values(); Iterator iter = set.iterator(); while (iter.hasNext()) { System.out.println(iter.next()); }//from w ww .j a v a 2s . c o m }
From source file:Main.java
public static void main(String[] args) { TreeMap<String, String> treeMap = new TreeMap<String, String>(); treeMap.put("1", "One"); treeMap.put("2", "Two"); treeMap.put("3", "Three"); Collection c = treeMap.values(); Iterator itr = c.iterator(); while (itr.hasNext()) { System.out.println(itr.next()); }//from ww w. j ava2 s . c o m }
From source file:Main.java
public static void main(String[] a) { Map<String, String> map = new HashMap<String, String>(); map.put("key1", "value1"); map.put("key2", "value2"); map.put("key3", "value3"); Collection set = map.values(); Iterator iter = set.iterator(); while (iter.hasNext()) { System.out.println(iter.next()); }/*w w w .ja v a2 s .com*/ }
From source file:Main.java
public static void main(String[] args) { HashMap<String, String> hMap = new HashMap<String, String>(); hMap.put("1", "One"); hMap.put("2", "Two"); hMap.put("3", "Three"); Collection c = hMap.values(); Iterator itr = c.iterator(); while (itr.hasNext()) { System.out.println(itr.next()); }/* w w w . j av a2 s . c om*/ }
From source file:Main.java
public static void main(String[] args) { LinkedHashMap<String, String> lHashMap = new LinkedHashMap<String, String>(); lHashMap.put("1", "One"); lHashMap.put("2", "Two"); lHashMap.put("3", "Three"); Collection c = lHashMap.values(); Iterator itr = c.iterator(); while (itr.hasNext()) { System.out.println(itr.next()); }//from w w w . j a va 2s. co m }
From source file:Main.java
public static void main(String[] args) { Hashtable<String, String> ht = new Hashtable<String, String>(); ht.put("1", "One"); ht.put("2", "Two"); ht.put("3", "Three"); Collection c = ht.values(); Iterator itr = c.iterator(); while (itr.hasNext()) { System.out.println(itr.next()); }//from w w w. j av a2 s. c o m c.remove("One"); Enumeration e = ht.elements(); while (e.hasMoreElements()) { System.out.println(e.nextElement()); } }
From source file:Main.java
public static void main(String[] args) throws Exception { File root = new File("c:\\"); String[] extensions = { "xml", "java", "dat" }; boolean recursive = true; Collection files = FileUtils.listFiles(root, extensions, recursive); for (Iterator iterator = files.iterator(); iterator.hasNext();) { File file = (File) iterator.next(); System.out.println("File = " + file.getAbsolutePath()); }/* ww w .j ava2 s.co m*/ }
From source file:MainClass.java
public static void main(String[] a) { Collection c = new ArrayList(); c.add("1");/*www . j a va 2s. co m*/ c.add("2"); c.add("3"); Iterator i = c.iterator(); while (i.hasNext()) { System.out.println(i.next()); } }
From source file:Main.java
public static void main(String[] a) { Collection<String> c = new ArrayList<String>(); c.add("1");/*ww w. ja va 2 s . c om*/ c.add("2"); c.add("3"); Iterator i = c.iterator(); while (i.hasNext()) { System.out.println(i.next()); } }
From source file:list.Main.java
public static void main(String[] args) throws Exception { Options options = getOptions();/*from w w w .j a v a 2 s.c om*/ try { CommandLineParser parser = new GnuParser(); CommandLine line = parser.parse(options, args); File dir = new File(line.getOptionValue("dir", ".")); Collection files = ListFile.list(dir); System.out.println("listing files in " + dir); for (Iterator it = files.iterator(); it.hasNext();) { System.out.println("\t" + it.next() + "\n"); } } catch (ParseException exp) { // oops, something went wrong System.err.println("Parsing failed. Reason: " + exp.getMessage()); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("list", options); } }