One:
Map, he is composed of a set of double columns, namely: Key=value form.
1 Package test12;2 3Import java.util.*;4 5 Public classMap_demo {6 Public Static voidMain (String...args) {7 Map_demo ();8 }9 Public Static voidMap_demo () {TenMap<string,integer> per_info=NewHashmap<>(); OnePer_info.put ("Tom", A);//Set key Val APer_info.put ("Tom", A); -Per_info.put ("OK", A); -Set<string> Key=per_info.keyset ();//gets the collection of keys. Because key is unordered. theIterator<string> k_it=key.iterator (); - while(K_it.hasnext ()) { -System. out. Print (K_it.next ()); - } + } -}
which
V put (K,V) inserts key, Val. The map method requires that key cannot be duplicated, but if the inserted key is duplicated, it will not be an error.
Set keyset () Gets the key collection for the map, noting that the type is set.
Where the Put method returns a value of V, the value that is overwritten. Only if the same key value is overwritten. If the newly inserted value is null.
1 Package test12;2 3Import java.util.*;4 5 Public classMap_demo {6 Public Static voidMain (String...args) {7 Map_demo ();8 }9 Public Static voidMap_demo () {TenMap<string,integer> per_info=NewHashmap<>(); OneInteger I=per_info.put ("Tom", A);//Set key Val AInteger J=per_info.put ("Tom", A); -Per_info.put ("OK", A); -System. out. Print (i); theSystem. out. Print (j); -Set<string> Key=per_info.keyset ();//gets the collection of keys. Because key is unordered. -Iterator<string> k_it=key.iterator (); - while(K_it.hasnext ()) { +System. out. Print (K_it.next ()); - } + } A}
Java Map uses