java4all@1986 java. Powered by Blogger.

Methods of Map.entry Interface?

>> Monday, May 30, 2011

Map.Entry is an Interface ,it consists of  some methods.
   public  Object getKey(){};
  public Object getValue(){};

These methods can be used to get key and value fro a map;

Sample program:
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 iter = props.entrySet().iterator();

    while (iter.hasNext()) {
      Map.Entry entry = (Map.Entry) iter.next();
      System.out.println(entry.getKey() + " -- " + entry.getValue());
    }

  }
}

OUTPUT::
sun.cpu.endian -- little
sun.desktop -- windows
sun.cpu.isalist --
 The output we got from system property files.

0 comments:

Post a Comment

FaceBook Login

HTML/JAVASCRIPT

HTML/JAVASCRIPT

HTML/JAVASCRIPT

HTML/JAVASCRIPT

Total Pageviews

STATCOUNTER

  © Blogger template Simple n' Sweet by Ourblogtemplates.com 2009

Back to TOP