Example usage for java.util Iterator hasNext

List of usage examples for java.util Iterator hasNext

Introduction

In this page you can find the example usage for java.util Iterator hasNext.

Prototype

boolean hasNext();

Source Link

Document

Returns true if the iteration has more elements.

Usage

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");

    Set st = lHashMap.keySet();//from  w  w w  .j a v  a2  s . com

    Iterator itr = st.iterator();

    while (itr.hasNext()) {
        System.out.println(itr.next());
    }
    st.remove("2");

    boolean blnExists = lHashMap.containsKey("2");
    System.out.println(blnExists);
}

From source file:Main.java

public static void main(String[] args) {
    String[] coins = { "A", "B", "C", "D", "E" };

    List src = new LinkedList();
    for (int i = 0; i < coins.length; i++) {
        src.add(coins[i]);//from   ww w.  jav  a  2s  .c  o  m
    }

    System.out.println(src);

    Collections.fill(src, "java2s.com");

    Iterator liter = src.listIterator();

    while (liter.hasNext())
        System.out.println(liter.next());

}

From source file:Main.java

public static void main(String[] args) {
    Map<String, Charset> charsets = Charset.availableCharsets();
    Iterator<Charset> iterator = charsets.values().iterator();
    while (iterator.hasNext()) {
        Charset cs = (Charset) iterator.next();
        System.out.println(cs.aliases());
    }/*www. ja  v  a 2s .  c  om*/
}

From source file:Main.java

public static void main(String[] args) {
    Map<String, Charset> charsets = Charset.availableCharsets();
    Iterator<Charset> iterator = charsets.values().iterator();
    while (iterator.hasNext()) {
        Charset cs = (Charset) iterator.next();
        System.out.print(cs.displayName());
    }//from  w  ww.  ja v  a 2s  .c om
}

From source file:Main.java

public static void main(String[] args) {
    Map<String, Charset> charsets = Charset.availableCharsets();
    Iterator<Charset> iterator = charsets.values().iterator();
    while (iterator.hasNext()) {
        Charset cs = (Charset) iterator.next();
        System.out.print(cs.displayName(Locale.getDefault()));
    }/*from   www  . j a va  2 s . c o  m*/
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Iterator it = Arrays.asList("a", "b", "java2s.com").iterator();
    while (it.hasNext()) {
        String key = it.next().toString();
        System.out.println(key);//w w  w  .j  ava 2s . c  o  m
    }
}

From source file:Main.java

public static void main(String[] args) {
    Map<String, Charset> charsets = Charset.availableCharsets();
    Iterator<Charset> iterator = charsets.values().iterator();
    while (iterator.hasNext()) {
        Charset cs = (Charset) iterator.next();
        System.out.println(cs.displayName());
        System.out.println(cs.hashCode());
    }//from   w  ww. j  av  a  2  s . co  m
}

From source file:Main.java

public static void main(String[] args) {
    Map<String, Charset> charsets = Charset.availableCharsets();
    Iterator<Charset> iterator = charsets.values().iterator();
    while (iterator.hasNext()) {
        Charset cs = (Charset) iterator.next();
        System.out.println(cs.displayName());
        System.out.println(cs.toString());
    }//from   w w w. ja  v  a  2 s .co  m
}

From source file:DumpProps.java

public static void main(String args[]) {
    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());
    }/* w  w w .jav a 2 s . c o  m*/

    System.out.println("-------");

    Enumeration e = props.propertyNames();
    while (e.hasMoreElements()) {
        String key = (String) e.nextElement();
        System.out.println(key + " --- " + props.getProperty(key));
    }
}

From source file:Main.java

public static void main(String[] args) {
    Map<String, Charset> charsets = Charset.availableCharsets();
    Iterator<Charset> iterator = charsets.values().iterator();
    while (iterator.hasNext()) {
        Charset cs = (Charset) iterator.next();
        System.out.println(cs.displayName());
        System.out.println(cs.name());
    }//from w w  w.ja  va  2s. c o m
}