stay Map In the set

values(): Method is to get all the values in the collection ---- There is no key , There is no correspondence ,

KeySet():
take Map All the keys in the set In the set . because set With iterator . All keys can be retrieved iteratively , Again according to get method . Get the value of each key .
keySet(): After iteration, it can only pass through get() take key

entrySet():
Set<Map.Entry<K,V>> entrySet() // Of the mapping relationship contained in this map Set view .
Map.Entry Represents the mapping relationship .entrySet(): After iteration, we can e.getKey(),e.getValue() take key and value. What's coming back is Entry Interface .
package xtgis.controller; import java.util.HashMap; import java.util.Iterator;
import java.util.Map; public class test { public static void main(String[]
args) { HashMap<String, String> map = new HashMap<>(); map.put("11", "1");
map.put("22", "2"); map.put("33", "3"); map.put("44", "4"); map.put("55", "5");
map.put("66", "6"); map.put("88", "8"); map.put("99", "9"); show_1(map);
System.out.println("\n"); show_2(map); System.out.println("\n"); show_3(map);
System.out.println("\n"); show_4(map); } public static void show_1(Map<String,
String> map) { for (String key : map.keySet()) { System.out.println("Key=" +
key + " Value=" + map.get(key)); } } public static void show_2(Map<String,
String> map) { Iterator<Map.Entry<String, String>> maplist =
map.entrySet().iterator(); while (maplist.hasNext()) { Map.Entry<String,
String> entry = maplist.next(); System.out.println("Key=" + entry.getKey() + "
Value=" + entry.getValue()); } } public static void show_3(Map<String, String>
map) { for (Map.Entry<String, String> entry : map.entrySet()) {
System.out.println("Key=" + entry.getKey() + " Value=" + entry.getValue()); } }
public static void show_4(Map<String, String> map) { for (String value :
map.values()) { System.out.println("Value= " + value); } } } Operation results :
Key=11 Value=1
Key=22 Value=2
Key=33 Value=3
Key=44 Value=4
Key=55 Value=5
Key=66 Value=6
Key=88 Value=8
Key=99 Value=9

Key=11 Value=1
Key=22 Value=2
Key=33 Value=3
Key=44 Value=4
Key=55 Value=5
Key=66 Value=6
Key=88 Value=8
Key=99 Value=9

Key=11 Value=1
Key=22 Value=2
Key=33 Value=3
Key=44 Value=4
Key=55 Value=5
Key=66 Value=6
Key=88 Value=8
Key=99 Value=9

Value= 1
Value= 2
Value= 3
Value= 4
Value= 5
Value= 6
Value= 8
Value= 9

Technology