使用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循环。

posted @ 2019-01-04 22:53  WW_Hai  阅读(141)  评论(0编辑  收藏  举报