1. Describe the HASHMAP internal implementation principle.
2. Describe the difference between hashset and HashMap.
3. The collection of grades uses a nested implementation of map.
Class 10, 50 people per class.
4. Programming to achieve copy of text files. The reasonable design procedure, obtains the buffer area the size high efficiency interval.
The prompt buffer setting starts at 1k and does not exceed 10M.
----------------------------------------------------------------------
1.HashMap is k-v, hashmap the bottom of the hash algorithm, is a keyword-based search algorithm, improve the HashMap find speed. HashMap gets an address by hashcode and equals compares the elements in the linked list, taking out the corresponding value value.
2.hashset implements key with HashMap, implements the set interface, inherits the collection interface
HASHMAP: Implement the Map interface, with the hash mechanism to store, do not repeat, set and map is the same level.
3.
Package practice;import java.util.hashmap;import java.util.map;import java.util.map.entry The/* ** grade collection uses a nested implementation of map. *10 class, 50 people per class. */public class mapdemo {public static void main (String[] args) { todo auto-generated method stub//class Collection Map<integer , map<string,string >> classes=new HashMap<Integer,Map<String,String>> ();//List Collection map<string,string > names=null;int no=1;//Add a list of classes and classes for (int i=0;i<10;i++) {names=new hashmap< String, string> (); Classes.put (i,names); for (int j=0;j<50;j++) {names.put (i+ ".") +j , "Tom" +no); no++;}} Traverse class Collection Entrysetfor (Entry<integer,map<string,string>> entry : classes.entryset ()) {/ /class Integer classno=entry.getkey ();//class member Map<string,string> banji=entry.getvalue ();//Traverse all personnel for ( Entry<string,string> entry0 : banji.entryset ()) {//study number String stuno=entry0.getkey ();//name String nameno=entry0.getvalue (); System.out.println (classno + " ===> " + stuno + " --> " + nameno) ;} Use KeySet to traverse for (Integer classnum : classes.keyset ()) {map<string,string> map= Classes.get (Classnum); for (String stun : map.keyset ()) {string name=map.get (StuN);//String num=map.ge}}}}
Big Data Day 12th