🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
## Map遍历 >包含key和value的遍历 ``` // 定义map HashMap<String, String> settings = new HashMap<String, String>(); for (Entry<String, String> setting : settings.entrySet()) { System.out.println("这里是key:" + setting.getKey() + "; 这里是value:" + setting.getValue() + "。"); } ``` >只需要key的情况 ``` // 定义map HashMap<String, String> settings = new HashMap<String, String>(); for (String key : settings.getKeys()) { System.out.println("这里是key:" + key + "。"); } ``` >只需要value的情况 ``` // 定义map HashMap<String, String> settings = new HashMap<String, String>(); for (String value : settings.getKeys()) { System.out.println("这里是value:" + value + "。"); } ```