Function: @author crossoverJie Date: 05/05/2018 12:42 @since JDK 1.8
| 13 | * @since JDK 1.8 |
| 14 | */ |
| 15 | public class HashMapTest { |
| 16 | public static void main(String[] args) { |
| 17 | Map<String, Integer> map = new HashMap<>(16); |
| 18 | map.put("1", 1); |
| 19 | map.put("2", 2); |
| 20 | map.put("3", 3); |
| 21 | map.put("4", 4); |
| 22 | |
| 23 | Iterator<Map.Entry<String, Integer>> entryIterator = map.entrySet().iterator(); |
| 24 | while (entryIterator.hasNext()) { |
| 25 | Map.Entry<String, Integer> next = entryIterator.next(); |
| 26 | System.out.println("key=" + next.getKey() + " value=" + next.getValue()); |
| 27 | } |
| 28 | System.out.println("============="); |
| 29 | |
| 30 | Iterator<String> iterator = map.keySet().iterator(); |
| 31 | while (iterator.hasNext()){ |
| 32 | String key = iterator.next(); |
| 33 | System.out.println("key=" + key + " value=" + map.get(key)); |
| 34 | |
| 35 | } |
| 36 | |
| 37 | System.out.println("============="); |
| 38 | map.forEach((key, value) -> { |
| 39 | System.out.println("key=" + key + " value=" + map.get(key)); |
| 40 | }); |
| 41 | } |
| 42 | } |
nothing calls this directly
no outgoing calls
no test coverage detected