Java Properties iterate via map entry values

Description

Java Properties iterate via map entry values

import java.util.Iterator;
import java.util.Map;
import java.util.Properties;

public class Main {
  public static void main(String[] a) {
    Properties props = System.getProperties();
    Iterator<Map.Entry<Object,Object>> iter = props.entrySet().iterator();

    while (iter.hasNext()) {
      Map.Entry<Object,Object> entry = (Map.Entry<Object,Object>) iter.next();
      System.out.println(entry.getKey() + " -- " + entry.getValue());
    }/* w  w w  .j  ava2 s  .c o  m*/

  }
}



PreviousNext

Related