JAVA gets the values in the map
-
Map<string, string> map=new hashmap<string, string> (); Map.put ("name", "Lao Wei"); Map.put ("Sex", "male"); Map.put ("Address", "Dalian");
-
Method 1
-
For (map.entry<string, string> MapString:map.entrySet ()) { String key=mapstring.getkey ();//Times method Gets the name of the key-value pair String Value=mapstring.getvalue ();//Secondary method gets the value of a key-value pair System.out.println (key+ ":" +value);
-
-
Method 2
-
for (Iterator Iterator = Set.iterator (); Iterator.hasnext ();) { Map.entry string = (map.entry) iterator.next (); String key= ((entry<string, string>) string). GetKey ();//Times method Gets the name of the key-value pair String value= ((entry<string, string >). GetValue ();//Times method Gets the value of a key-value pair
-
Method 3
Map map = new HashMap (), Map.put ("Dog", "dogs"), Map.put ("Cat", "cat"), Map.put ("Monkey", "monkey"); for (Object Se:map.keySet ()) { string s = (string) map.get (SE); System.out.println (s);}
JAVA gets the values in the map