使用java显示所有操作系统环境变量

public class EnvironmentVariables{

     public static void main(String[] args){

          for(Map.Entry entry: System.genten().entrySet.()){

             System.out.println(entry.getKey() + ": "+entry.getValue());

         }

     }

}

System.getenv()返回一个Map,entrySet()产生一个由Map.Entry的元素构成的Set,并且设个Set是一个Interable,因此它可以用于foreach循环。

猜你喜欢

转载自www.cnblogs.com/wwhai/p/10222932.html