HashMap siv li cas hauv Java nrog piv txwv?
HashMap siv li cas hauv Java nrog piv txwv?

Video: HashMap siv li cas hauv Java nrog piv txwv?

Video: HashMap siv li cas hauv Java nrog piv txwv?
Video: TdP-2017-L23 Albero di visita 2024, Kaum ib hlis
Anonim

HashMap hauv Java nrog Piv txwv . HashMap yog ib daim ntawv qhia raws li chav kawm sau uas yog siv rau khaws Key & nqi khub, nws yog denoted li HashMap los yog HashMap . Nws tsis yog ib qho kev txiav txim sau uas txhais tau tias nws tsis rov qab cov yuam sij thiab qhov tseem ceeb hauv tib qho kev txiav txim uas lawv tau muab tso rau hauv HashMap.

Hais txog qhov no, HashMap yog dab tsi hauv Java?

Java HashMap yog lub rooj hash raws li kev siv ntawm Java cov Daim ntawv qhia interface. Daim Ntawv Qhia, raws li koj tuaj yeem paub, yog ib qho kev sau ntawm cov khub tseem ceeb. Java HashMap tso cai null qhov tseem ceeb thiab tus yuam sij null. HashMap yog ib qho khoom sau tsis raug. Nws tsis lav ib qho kev txiav txim tshwj xeeb ntawm cov khoom.

koj tsim ib daim ntawv qhia hash li cas? Ntawm no, peb pom ntau txoj hauv kev los ntxig cov ntsiab lus.

  1. import java.util.*;
  2. chav HashMap1{
  3. public static void main(String args){
  4. HashMap hm=new HashMap();
  5. System.out.println("Cov npe thawj zaug: "+hm);
  6. hm.put(100, "Amit");
  7. hm.put(101, "Vij");
  8. hm.put(102, "Rahul");

Raws li txoj cai, peb siv HashMap qhov twg hauv Java?

Maps tau siv rau thaum koj xav koom nrog tus yuam sij nrog tus nqi thiab Cov Ntawv Teev Npe yog cov ntawv xaj xaj. Daim ntawv qhia yog ib qho interface hauv lub Java Collection Framework thiab a HashMap yog ib qho kev siv ntawm Map interface. HashMap muaj txiaj ntsig rau kev nrhiav tus nqi raws li tus yuam sij thiab ntxig thiab tshem tawm qhov tseem ceeb raws li tus yuam sij.

HashMap khaws cov nqi tseem ceeb li cas?

HashMaps siv cov chav kawm sab hauv khw data: nkag. Qhov kev nkag no yog qhov yooj yim tus yuam sij - tus nqi khub nrog ob cov ntaub ntawv ntxiv: ib qho kev siv rau lwm qhov nkag kom a HashMap ua tau khw nkag zoo li cov npe txuas ib leeg. ib hash tus nqi uas sawv cev rau tus hash tus nqi ntawm tus yuam sij.

Pom zoo: