List of usage examples for java.util Iterator hasNext
boolean hasNext();
From source file:Main.java
public static void main(String[] argv) throws Exception { int capacity = 10; ArrayBlockingQueue<Integer> queue = new ArrayBlockingQueue<Integer>(capacity); for (int i = 0; i < 10; i++) { queue.add(i);//from www. j a v a 2 s . c o m } Iterator<Integer> it = queue.iterator(); while (it.hasNext()) { System.out.println(it.next()); } }
From source file:Main.java
public static void main(String args[]) { LinkedList<String> ll = new LinkedList<String>(); ll.add("A");/* ww w. ja v a 2 s . co m*/ ll.add("ja v a2s.com"); ll.addLast("B"); ll.add("C"); Iterator<String> itr = ll.iterator(); while (itr.hasNext()) { String element = itr.next(); System.out.print(element + " "); } }
From source file:Main.java
public static void main(String[] argv) { Map map = new HashMap(); map.put("Adobe", "Mountain View, CA"); map.put("IBM", "White Plains, NY"); map.put("Learning Tree", "Los Angeles, CA"); Iterator k = map.keySet().iterator(); while (k.hasNext()) { String key = (String) k.next(); System.out.println("Key " + key + "; Value " + (String) map.get(key)); }//from w w w . j av a2s. c o m }
From source file:MainClass.java
public static void main(String[] args) { Map charsets = Charset.availableCharsets(); Iterator iterator = charsets.keySet().iterator(); while (iterator.hasNext()) { System.out.println(iterator.next()); }/*w ww.ja v a2 s .com*/ }
From source file:MainClass.java
public static void main(String[] a) { Properties props = System.getProperties(); Iterator iter = props.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); System.out.println(entry.getKey() + " -- " + entry.getValue()); }//from ww w .j a v a2 s. com }
From source file:MainClass.java
public static void main(String[] args) throws Exception { CertificateFactory cf = CertificateFactory.getInstance("X.509"); FileInputStream in = new FileInputStream(args[0]); X509CRL crl = (X509CRL) cf.generateCRL(in); Set s = crl.getRevokedCertificates(); if (s != null && s.isEmpty() == false) { Iterator t = s.iterator(); while (t.hasNext()) { X509CRLEntry entry = (X509CRLEntry) t.next(); System.out.println("serial number = " + entry.getSerialNumber().toString(16)); System.out.println("revocation date = " + entry.getRevocationDate()); System.out.println("extensions = " + entry.hasExtensions()); }//from w w w. j a v a 2 s . c o m } in.close(); }
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"); Set st = hMap.keySet();/*from w w w .j av a 2 s . co m*/ Iterator itr = st.iterator(); while (itr.hasNext()) System.out.println(itr.next()); // remove 2 from Set st.remove("2"); System.out.println(hMap.containsKey("2")); }
From source file:Main.java
public static void main(String[] args) { Vector<Integer> vec = new Vector<Integer>(); vec.add(4);//from w ww.jav a 2 s . c o m vec.add(3); vec.add(2); vec.add(1); System.out.println(vec); Iterator<Integer> it = vec.iterator(); while (it.hasNext()) { System.out.println(it.next()); } }
From source file:Main.java
public static void main(String[] args) throws IOException { String fileContent = "s1=1\n" + "s2=Main\n" + "s3=Fri Jan 31 00:00:00 IST 3913"; StringReader reader = new StringReader(fileContent); PropertyResourceBundle bundle = new Main(reader); Set keySet = bundle.handleKeySet(); Iterator keys = keySet.iterator(); while (keys.hasNext()) { System.out.println("Bundle key: " + keys.next()); }//w ww.j ava2 s .com }
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();//from w w w .j av a2s. c om Iterator itr = c.iterator(); while (itr.hasNext()) { System.out.println(itr.next()); } c.remove("One"); Enumeration e = ht.elements(); while (e.hasMoreElements()) { System.out.println(e.nextElement()); } }