Stream versus Iterator in entrySet of a Map
问题 To my understanding, the following code should print true , since both Stream and Iterator are pointing to the first element. However, when I run the following code it is printing false : final HashMap<String, String> map = new HashMap<>(); map.put("A", "B"); final Set<Map.Entry<String, String>> set = Collections.unmodifiableMap(map).entrySet(); Map.Entry<String, String> entry1 = set.iterator().next(); Map.Entry<String, String> entry2 = set.stream().findFirst().get(); System.out.println