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:
sun.desktop -- windows
sun.cpu.isalist --
The output we got from system property files.
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 -- littlesun.desktop -- windows
sun.cpu.isalist --
The output we got from system property files.
0 comments:
Post a Comment