java.java (461B)
1 import java.util.Map; 2 import java.util.TreeSet; 3 4 public class GetEnv { 5 /** 6 * let's test generics 7 * @param args the command line arguments 8 */ 9 public static void main(String[] args) { 10 // get a map of environment variables 11 Map<String, String> env = System.getenv(); 12 // build a sorted set out of the keys and iterate 13 for(String k: new TreeSet<String>(env.keySet())) { 14 System.out.printf("%s = %s\n", k, env.get(k)); 15 } 16 } }