标签:reac hashmap ati printf rgs www color bsp entry
1 package collections; 2 3 import java.util.HashMap; 4 5 public class HashMapDemo { 6 7 public static void main(String[] args) { 8 HashMap<String, String> map = new HashMap<String, String>(); 9 // 添加内容,内容以key/value方式填入 10 map.put("湘南IT培训", "https://www.0735it.com/"); 11 map.put("google","https://www.google.com/"); 12 map.put("利永贞网","https://www.liyongzhen.com"); 13 14 // java 5 for 方式遍历;后进先出来 15 for(String key:map.keySet()) { 16 System.out.printf("key %s;\nvalue %s\n",key,map.get(key)); 17 } 18 19 // java 8 forEach 方式遍历 20 map.entrySet().forEach(e-> 21 System.out.printf("key %s;\nvalue %s\n",e.getKey(),e.getValue()) 22 ); 23 } 24 25 }
标签:reac hashmap ati printf rgs www color bsp entry
原文地址:https://www.cnblogs.com/q2546/p/11395817.html