Example usage for java.util Map entrySet

List of usage examples for java.util Map entrySet

Introduction

In this page you can find the example usage for java.util Map entrySet.

Prototype

Set<Map.Entry<K, V>> entrySet();

Source Link

Document

Returns a Set view of the mappings contained in this map.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Map map = new HashMap();
    for (Iterator it = map.entrySet().iterator(); it.hasNext();) {
        Map.Entry entry = (Map.Entry) it.next();
        Object key = entry.getKey();
        Object value = entry.getValue();
    }//w w  w. java2s. c  o  m
}

From source file:Main.java

public static void main(String args[]) {
    System.out.println("PATH = " + System.getenv("PATH"));

    Map env = System.getenv();
    for (Iterator it = env.entrySet().iterator(); it.hasNext();) {
        Map.Entry entry = (Map.Entry) it.next();
        System.out.println(entry.getKey() + " = " + entry.getValue());
    }// w  ww. ja v a2  s.c o m
}

From source file:Main.java

public static void main(String args[]) {
    System.out.println("PATH = " + System.getenv("PATH"));

    Map<String, String> env = System.getenv();
    for (Iterator<Map.Entry<String, String>> it = env.entrySet().iterator(); it.hasNext();) {
        Map.Entry<String, String> entry = it.next();
        System.out.println(entry.equals(entry));
    }/*from w  w w .  j a  v a 2 s . co m*/
}

From source file:Main.java

public static void main(String args[]) {
    System.out.println("PATH = " + System.getenv("PATH"));

    Map<String, String> env = System.getenv();
    for (Iterator<Map.Entry<String, String>> it = env.entrySet().iterator(); it.hasNext();) {
        Map.Entry<String, String> entry = it.next();
        System.out.println(entry.hashCode());
    }/*from   w  ww. ja v  a  2s .c  om*/
}

From source file:Main.java

public static void main(String args[]) {
    System.out.println("PATH = " + System.getenv("PATH"));

    Map<String, String> env = System.getenv();
    for (Iterator<Map.Entry<String, String>> it = env.entrySet().iterator(); it.hasNext();) {
        Map.Entry<String, String> entry = it.next();
        System.out.println(entry.getKey() + " = " + entry.getValue());
    }// w w  w .j a v  a  2s  .  co  m
}

From source file:Main.java

public static void main(String args[]) {
    System.out.println("PATH = " + System.getenv("PATH"));

    Map<String, String> env = System.getenv();
    for (Iterator<Map.Entry<String, String>> it = env.entrySet().iterator(); it.hasNext();) {
        Map.Entry<String, String> entry = it.next();
        entry.setValue("None");
    }//from w w  w  . j  a  v  a2s. c  o m
}

From source file:SyncTest.java

public static void main(String args[]) {
    Set simpsons = new HashSet();
    simpsons.add("Bart");
    simpsons.add("Hugo");
    simpsons.add("Lisa");
    simpsons.add("Marge");
    simpsons.add("Homer");
    simpsons.add("Maggie");
    simpsons.add("Roy");
    simpsons = Collections.synchronizedSet(simpsons);
    synchronized (simpsons) {
        Iterator iter = simpsons.iterator();
        while (iter.hasNext()) {
            System.out.println(iter.next());
        }/*from ww  w  .ja v  a  2s. c o  m*/
    }
    Map map = Collections.synchronizedMap(new HashMap(89));
    Set set = map.entrySet();
    synchronized (map) {
        Iterator iter = set.iterator();
        while (iter.hasNext()) {
            System.out.println(iter.next());
        }
    }
}

From source file:MainClass.java

public static void main(String args[]) {
    Set simpsons = new HashSet();
    simpsons.add("B");
    simpsons.add("H");
    simpsons.add("L");
    simpsons = Collections.synchronizedSet(simpsons);
    synchronized (simpsons) {
        Iterator iter = simpsons.iterator();
        while (iter.hasNext()) {
            System.out.println(iter.next());
        }/*from   www  . j  a  v  a2s.co m*/
    }
    Map map = Collections.synchronizedMap(new HashMap(89));
    Set set = map.entrySet();
    synchronized (map) {
        Iterator iter = set.iterator();
        while (iter.hasNext()) {
            System.out.println(iter.next());
        }
    }
}

From source file:Main.java

public static void main(String[] args) {
    Properties properties = new Properties();

    properties.setProperty("name", "Designer");
    properties.setProperty("version", "1.0");
    properties.setProperty("vendor", "Inc");

    Map<String, String> map = new HashMap<String, String>((Map) properties);

    Set propertySet = map.entrySet();
    for (Object o : propertySet) {
        Map.Entry entry = (Map.Entry) o;
        System.out.printf("%s = %s%n", entry.getKey(), entry.getValue());
    }//from w  w w . ja va2 s.  c  om
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    URL url = new URL("http://www.java2s.com/");
    URLConnection urlConnection = url.openConnection();
    Map<String, List<String>> headers = urlConnection.getHeaderFields();
    Set<Map.Entry<String, List<String>>> entrySet = headers.entrySet();
    for (Map.Entry<String, List<String>> entry : entrySet) {
        String headerName = entry.getKey();
        System.out.println("Header Name:" + headerName);
        List<String> headerValues = entry.getValue();
        for (String value : headerValues) {
            System.out.print("Header value:" + value);
        }/*w w w  . jav a  2s  .  c o  m*/
        System.out.println();
    }
}