Big Data Day 12th

Source: Internet
Author: User


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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.