Java Map.Entry.getKey()
Syntax
Map.Entry.getKey() has the following syntax.
K getKey()
Example
In the following code shows how to use Map.Entry.getKey() method.
//w w w .j av a 2 s. c o m
import java.util.Iterator;
import java.util.Map;
public class Main {
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());
}
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »