First, Introduction
Typically, a map is a data structure that consists of key-value pairs, and each key in the collection is unique.
Second, notes
/*** Map: interface. Not collection sub-class Key-value key value pair key unique cannot repeat * when the same key is used again to save the data will overwrite the value values of the previous key * * HashMap: The underlying is a hash table, key conforms to the hash table character * Treemap: Bottom The layer is a two-fork tree *@authorHutiger **/ Public classMapstudy { Public Static voidMain (string[] args) {myMap (); } Public Static voidMyMap () {Map<string, object> map =NewHashmap<string, object>(); Map.put ("A", "Aa-aa"); Map.put ("B", "BB-BB"); Map.put ("C", "CC-CC"); Map.put ("D", "DD-DD"); //Get Method//System.out.println (Map.get ("a")); //How to traverse mapset<entry<string, object>> sets = Map.entryset ();//put the data in the map into set//iterator<entry<string, object>> itsiterator=sets.iterator (); //While (Itsiterator.hasnext ()) {//map.entry<string, object> Entry = (map.entry<string, object>)//Itsiterator//. Next (); // } for(Entry<string, object>entry:sets) {System.out.println (Entry.getkey ()+ "= +" +Entry.getvalue ()); } //set<string> keys = Map.keyset (); //For (String string:keys) {//System.out.println (Map.get (keys)); // } } Public Static voidTest () {//the total number of pages of data for a scene transfer the current page of datalist<user> list =NewArraylist<user>(); List.add (NewUser ("admin")); List.add (NewUser ("admin")); List.add (NewUser ("admin")); List.add (NewUser ("admin")); intPages=30; Map<string, object> map =NewHashmap<string, object>(); Map.put ("List", list); Map.put ("Page", pages); } }
Java Learning notes: Java Map collection